How to install mysql on FreeBSD 10.1

Install MySQL

To install MySQL 5.6 using pkg, use this command:

sudo pkg install mysql56-server
Enter y at the confirmation prompt. This installs the MySQL server and client packages. To enable MySQL server as a service, add mysql_enable=“YES” to the /etc/rc.conf file. This sysrc command will do just that:
sudo sysrc mysql_enable=yes
Now start the MySQL server:
sudo service mysql-server start
Now that your MySQL database is running, you will want to run a simple security script that will remove some dangerous defaults and slightly restrict access to your database system. Start the interactive script by running this command:
sudo mysql_secure_installation
The prompt will ask you for your current root password (the MySQL admin user, root). Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing RETURN. Then the prompt will ask you if you want to set a root password. Go ahead and enter Y, and follow the instructions.

Create a user for remote login

mysql -uroot -p

// allow user to log in from a specific host
create user 'Username'@'11.11.11.1' identified by 'Abcd1234567';

// allow user to log in from anywhere
create user 'Username'@'%' identified by 'Abcd1234567';

// grant privileges to user
grant all privileges on *.* to 'qinking126'@'11.11.11.11';
grant all privileges on *.* to 'qinking126'@'%';

click here to learn more on how to create a new user and grant permissions in my sql