Installation, configuration and use of MySQL database under Linux

Installation, configuration and use of MySQL database under Linux

When installing and developing under Linux, it is often necessary to use the MySQL database. Let's take the Linux system as an example to explain how to install the MySQL database, how to enable/stop and stop the MySQL service, how to modify the configuration file of the MySQL database, and how to log in to the MySQL database. And modify the root user password, etc.

1) Check whether MySQL has been installed
in the system. Enter: sudo netstat -tap | grep mysql
or enter: mysql-version
[Explanation] The first command is to retrieve MySQL, and the second command is to query the installed version of MySQL. Judge according to the returned information.

2) To install the MySQL database,
enter: sudo apt-get install mysql-server mysql-client In the terminal console
, a dialog box will pop up during the installation process, prompting that the management password of the database root user needs to be set, and you can enter it according to the prompt. !

3) To test whether the installation is successful, repeat the first step!

4) Log in to MySQL and
enter in the terminal console: sudo -u root -p
When logging in, you are required to enter a password, and you can enter the correct root user password at this time!

5) Start and stop MySQL service
Start service command: sudo start mysql
Stop service command: sudo stop mysql

6) Modify MySQL administrator password
Modify command: sudo mysqladmin -u root password newpassword

7) Remote login (listen port)
By default, MySQL only listens to port 3306 of the local host IP address (127.0.0.1). You can modify its parameters by modifying the my.cnf configuration file.
For example: 
open the configuration file: sudo cat
/etc/mysql/my.cnf Use the # comment character and comment the bind-address= 127.0.0.1 statement to block the local IP address monitoring.

8) MySQL configuration file related directory
 #Database storage directory: /var/lib/mysql/
 #Startup script storage directory: /etc/rc.d/init.d/ #Related
 configuration file storage directory: /usr/share/mysql 
 # Relevant command storage directory: /usr/bin (mysqladminmysqldump and other commands)
 
9) MySQL graphical management software
  MySQLWorkbench
  Navicat
  phpmyadmin

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325336304&siteId=291194637