1. Install MySQL
Sudo apt-get install mysql-server
Sudo apt-get install mysql-client
Sudo apt-get install php5-mysql // The installation php5-mysql is to connect php to mysql
2. Check whether MySQL is running
Sudo netstat-tap | grep mysql
After running successfully, you can see a page similar to the following:
Image_1apg9c7o13rq6a0ne2n2d5qf9.png-5kB
If the server cannot run properly, run the following command to start it:
Sudo/ect/init. d/mysql restart
III. Uninstall MySQL
Sudo apt-get autoremove -- purge mysql-server-5.0
Sudo apt-get remove mysql-server
Sudo apt-get autoremove mysql-server
Sudo apt-get remove mysql-common (very important)
Clear residual data:
Dpkg-l | grep ^ rc | awk '{print $2}' | sudo xargs dpkg-P
4. Log on to MySQL
Mysql-uroot-p
Enter the correct password to enter:
5. Some simple MySQL operations:
5.1 start the MySQL service:
Sudo start mysql
5.2 stop the MySQL service:
Sudo stop mysql
5.3 modify the MySQL administrator password:
Sudo mysqladmin-u root password myNewPassword
5.4 modify the MySQL startup Port:
Sudo vi/ect/mysql/my. cnf
Port = 3306 // This port value is the MySQL startup port
5.5 directory structure after MySQL installation:
Note: This structure is only applicable to online installation using apt-get install.
Database storage directory:/var/lib/mysql /;
Related configuration file storage directory:/usr/share/mysql;
Directory for storing related commands:/usr/bin (mysqladmin mysqldump and other commands );
Startup step storage directory:/etc/rc. d/init. d /;
6. Remotely log on to the MySQL database
6.1 The Command format for MySQL remote access is as follows:
Mysql-h host address-u user name-p user password
For example, mysql-h192.168.1.20-uroot-p1234567890.
After configuring the data access permissions on the server, you cannot remotely access the MySQL database. Because you have not yet granted access permissions to databases or tables on the server ).
6.2 on the target server, modify the mysql my. cnf file:
Sudo vi/etc/mysql/my. cnf
Comment out bind-address to block local listening only:
# Bind-address = 127.0.0.1
Restart the MySQL service to make the modified configuration take effect:
Sudo restart mysql
6.3 grant access permissions to databases or tables on the server:
Grant all privileges on database name. * TO account @ "%" identified by "password ";
Flush privileges;
For example, grant all privileges on *. * TO root @ "%" identified by "1234567890"; flush privileges; to grant root the permission TO access ALL databases ON the host.
After the modification is complete, update the database modification configuration:
Flush privileges;
6.4 modify the user's IP address access limit to all IP addresses:
After logging on to the MySQL database on the server, modify the user's IP address access limit to all IP addresses:
Show databases; // display all databases
Use mysql; // switch to the database named mysql
Update user set host = '%' where user = 'root'; // modify the IP address of the root user to be unrestricted. "%" Indicates all IP addresses, or you can set it to a fixed IP address.
VII. MySQL graphical management software recommendation
Currently, mainstream MySQL graphical management software includes phpMyAdmin, MySQLDumper, MySQL GUI Tools, MySQL Workbench, and Navicat. I am currently using Navicat.
Last reminder:
Do not use the root account as the remote login account. Create a user!