Mysql on MAC El Capitan OS, Sierra OS. How to set reset new root password

mysql server mac

If you don't remember or need to reset mysql password on your mac , follow these steps:

1.Stop mysql server.
2. Open terminal and paste code below. It will run the server in safe mode with privilege bypass.

sudo mysqld_safe --skip-grant-tables

3. Open new terminal. Paste code below.

mysql -u root

4. For MySQL older than MySQL 5.7 use:

UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';

For MySQL 5.7+ use:

UPDATE mysql.user SET authentication_string=PASSWORD("new-password") WHERE User='root';

5. Now flush the permissions & quit.

FLUSH PRIVILEGES;
q

Hope it helps. Share if you like.

Cheers

Read more "Mysql on MAC El Capitan OS, Sierra OS. How to set reset new root password"

Xamarin Forms PCL How To Add Google Analytics, Android & iOS

Xamarin Logo Open Xamarin Studio or Visual Studio. Ill be using Xamarin Studio on Mac.

  1. Create project Xamarin forms , PCL.
Create Project Xamarin Studio
Create Project Xamarin Studio
Give Name to your project
Give Name
Project Structure
Project Structure

2. Now we need to import packages packages for both Android and iOS projects.

Import package for android project. Xamarin.GooglePlayService.Analytics

Google Play Services Analytics
Google Play Services Analytics

Import package for iOS project. Google Analytics for iOS

Google Analytics for iOS  Package.
Google Analytics for iOS Package

3. We need  initialize Google Analytics Service method at the application start

In Android project MainActivity / OnCreate insert 

GAService.GetGASInstance().Initialize_NativeGAS(this);

android initialize method

Do the same for  iOS project  AppDelegate / FinishedLaunching  insert

GAService.GetGASInstance().Initialize_NativeGAS();

iOS initialize method

4. In the main project create interface and add code below

using System;
namespace GoogleAnalyticsTest
{
    public interface IGAService
    {
        void Track_App_Page(String PageNameToTrack);

        void Track_App_Event(String GAEventCategory, String EventToTrack);

        void Track_App_Exception(String ExceptionMessageToTrack, Boolean isFatalException);
    }
}

5. Next, in android project lets create folder, name it Analytics and in that folder create class  and name it GAService.

Paste code below. Replace google tracking id with your one.

using System;
using Android.Content;
using Android.Gms.Analytics;
using Xamarin.Forms;

[assembly: Dependency(typeof(GoogleAnalyticsTest.Droid.GAService))]
namespace GoogleAnalyticsTest.Droid
{
    public class GAService : IGAService
    {
        //replace with your tracking id https://analytics.google.com/
        public string TrackingId = "UA-84011627-1";

        private static GoogleAnalytics GAInstance;
        private static Tracker GATracker;

        #region Instantiation ...
        private static GAService thisRef;
        public GAService()
        {
            // no code req'd
        }

        public static GAService GetGASInstance()
        {
            if (thisRef == null)
                // it's ok, we can call this constructor
                thisRef = new GAService();
            return thisRef;
        }
        #endregion

        public void Initialize_NativeGAS(Context AppContext = null)
        {
            GAInstance = GoogleAnalytics.GetInstance(AppContext.ApplicationContext);
            GAInstance.SetLocalDispatchPeriod(10);
            GATracker = GAInstance.NewTracker(TrackingId);
            GATracker.EnableExceptionReporting(true);
            GATracker.EnableAdvertisingIdCollection(true);
            GATracker.EnableAutoActivityTracking(true);
        }

        public void Track_App_Page(String PageNameToTrack)
        {
            GATracker.SetScreenName(PageNameToTrack);
            GATracker.Send(new HitBuilders.ScreenViewBuilder().Build());
        }

        public void Track_App_Event(String GAEventCategory, String EventToTrack)
        {
            HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder();
            builder.SetCategory(GAEventCategory);
            builder.SetAction(EventToTrack);
            builder.SetLabel("AppEvent");
            GATracker.Send(builder.Build());
        }

        public void Track_App_Exception(String ExceptionMessageToTrack, Boolean isFatalException)
        {
            HitBuilders.ExceptionBuilder builder = new HitBuilders.ExceptionBuilder();
            builder.SetDescription(ExceptionMessageToTrack);
            builder.SetFatal(isFatalException);
            GATracker.Send(builder.Build());
        }
    }

}

6. Do the same  in iOS project. Create folder, name it Analytics and in that folder create class  and name it GAService.

Paste code below. Replace google tracking id with your one.

using System;
using Foundation;
using Google.Analytics;
using Xamarin.Forms;

[assembly: Dependency(typeof(GoogleAnalyticsTest.iOS.GAService))]
namespace GoogleAnalyticsTest.iOS
{
    public class GAService : IGAService
    {
        //replace with your tracking id https://analytics.google.com/
        public string TrackingId = "UA-84011627-1";
        public ITracker Tracker;
        const string AllowTrackingKey = "AllowTracking";

        #region Instantition...
        private static GAService thisRef;
        public GAService()
        {
            // no code req'd
        }

        public static GAService GetGASInstance()
        {
            if (thisRef == null)
                // it's ok, we can call this constructor
                thisRef = new GAService();
            return thisRef;
        }
        #endregion

        public void Initialize_NativeGAS()
        {
            var optionsDict = NSDictionary.FromObjectAndKey(new NSString("YES"), new NSString(AllowTrackingKey));
            NSUserDefaults.StandardUserDefaults.RegisterDefaults(optionsDict);

            Gai.SharedInstance.OptOut = !NSUserDefaults.StandardUserDefaults.BoolForKey(AllowTrackingKey);

            Gai.SharedInstance.DispatchInterval = 10;
            Gai.SharedInstance.TrackUncaughtExceptions = true;

            Tracker = Gai.SharedInstance.GetTracker("Test App", TrackingId);
        }

        public void Track_App_Page(String PageNameToTrack)
        {
            Gai.SharedInstance.DefaultTracker.Set(GaiConstants.ScreenName, PageNameToTrack);
            Gai.SharedInstance.DefaultTracker.Send(DictionaryBuilder.CreateScreenView().Build());
        }

        public void Track_App_Event(String GAEventCategory, String EventToTrack)
        {
            Gai.SharedInstance.DefaultTracker.Send(DictionaryBuilder.CreateEvent(GAEventCategory, EventToTrack, "AppEvent", null).Build());
            Gai.SharedInstance.Dispatch(); // Manually dispatch the event immediately
        }

        public void Track_App_Exception(String ExceptionMessageToTrack, Boolean isFatalException)
        {
            Gai.SharedInstance.DefaultTracker.Send(DictionaryBuilder.CreateException(ExceptionMessageToTrack, isFatalException).Build());
        }
    }
}

7.  Now in our main project create new class lets name it GASCall,  you can give any name you like.

Copy paste code to you class from box below.

using System;
using Xamarin.Forms;

namespace GoogleAnalyticsTest
{
    public static class GASCall
    {
        public static void Track_App_Page(String PageNameToTrack)
        {
            DependencyService.Get<IGAService>().Track_App_Page(PageNameToTrack);
        }

        public static void Track_App_Event(String GAEventCategory, String EventToTrack)
        {
            DependencyService.Get<IGAService>().Track_App_Event(GAEventCategory, EventToTrack);
        }

        public static void Track_App_Exception(String ExceptionMessageToTrack, Boolean isFatalException)
        {
            DependencyService.Get<IGAService>().Track_App_Exception(ExceptionMessageToTrack, isFatalException);
        }
    }
}

8. In your main project create new class name it GAEventCategory. We will use it to track events. Copy/paste into your class code below.

using System;
namespace GoogleAnalyticsTest
{
    public struct GAEventCategory
    {
        public static String CountButton { get { return "Count Button"; } set { } }
        public static String Login { get { return "Login"; } set { } }
        public static String Logout { get { return "Logout"; } set { } }
    };
}

9. Finally create button we need it to test our app. Open main project main startup class.  In your GoogleAnlalyticsTestPage.xaml paste code below.

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:GoogleAnalyticsTest" x:Class="GoogleAnalyticsTest.GoogleAnalyticsTestPage">
    <StackLayout Padding="20">
        <Label Text="Google Analytics Example" VerticalOptions="Center" HorizontalOptions="Center"/>    
        <Button Text="CAll EVENT" Clicked ="OnClickButtonGoogleEventMethod" HorizontalOptions="FillAndExpand" HeightRequest="60" />
    </StackLayout>
</ContentPage>

10. Now add function ,  open GoogleAnlalyticsTestPage.xaml.cs and copy/paste code below.

using Xamarin.Forms;
using System;

namespace GoogleAnalyticsTest
{
    
    public partial class GoogleAnalyticsTestPage : ContentPage
    {
        private int counter = 0;

        public GoogleAnalyticsTestPage()
        {
            //will show up page name depending on what platform 
            //Android 
            if (Device.OS == TargetPlatform.Android)
            {
                //Track Page
                GASCall.Track_App_Page("Android HomePage");
            }
            //or iOS
            else {
                //Track Page
                GASCall.Track_App_Page("iOS HomePage");
            }

            InitializeComponent();

        }
        //button click to call events
        public void OnClickButtonGoogleEventMethod(object sender, EventArgs args)
        {
            GoogleAnalyticsEvents(GAEventCategory.CountButton, "Button Pressed "+ counter++);
        }

        //sending event to google analytics
        private void GoogleAnalyticsEvents( string Category, string EventToTrack) { 
                GASCall.Track_App_Event(Category, EventToTrack);

        }
    }
}

11. Last and final step.. lets test it.. ill be doing it on Android and iOS

 

  • Google Analytics
    Google Analytics
    Track events in Google Analytics
  • Google Analytics
    Google Analytics
    Track page in Google Analytics
  • Android Simulator
    Android Simulator
    Run Android simulator and click button few times
  • Google Analytics
    Google Analytics
    Tracks events in Google analytics
  • Google Analytics
    Google Analytics
    Tracks page in Google analytics
  • iOS Simulator
    iOS Simulator
    Run iOS simulator and click button few times

Fork it on GitHub      Xamarin Logo

 https://github.com/Sqube/-Xamarin-Forms-PCL-Google-Analytics-iOS-Android

Share if you like it .. Cheers

 

Read more "Xamarin Forms PCL How To Add Google Analytics, Android & iOS"