Install MySQL under Ubuntu and turn on remote access
February 07, 2017
One. Installing MySQL on Ubuntu is very simple and requires just a few commands to complete.
sudo apt-get install mysql-serverapt-get isntall mysql-clientsudo apt-get install libmysqlclient-dev
During installation, you will be prompted to set a password or something, note that the settings do not forget that after the installation is complete, you can use the following command to check if the installation is successful:
sudo netstat -tap | grep mysql
After checking with the above command, if you see a socket with MySQL in the Listen state, the installation is successful.
Log in to MySQL database by the following command:
mysql -u root -p
-U means to select the login user name,-p indicates the login user password, the above command input will prompt for a password, then enter the password can log in to MySQL.
Two. Turn on remote access
First step: vim/etc/mysql/my.cnf Find bind-address = 127.0.0.1
Comment out this line, such as: #bind-address = 127.0.0.1
or instead: Bind-address = 0.0.0.0 allows any IP access;
Or specify an IP address yourself.
RestartMySQL:sudo /etc/init.d/mysql restart
Step two: Authorize users to connect remotely
grant all privileges on *.* to [email protected]"%" identified by "password" with grant option;flush privileges;
The first line of the command is explained below. : The first represents the database name, and the second represents the name of the table. This means that all tables in the database are licensed to the user. Root: Grant root account. "%": indicates that the authorized user IP can be specified, which means that any IP address can access the MySQL database. "Password": Assign the password of the account, here the password itself is replaced with your MySQL root account password.
The second line of command is to refresh the permission information, that is, let our settings take effect immediately.
Ubuntu 14.03 Install MySQL