MySQL is the most popular relational database management system. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) application software.
Download the MySQL installation file
The following two files are required to install MySQL. All can be downloaded from the official website.
The installation commands for the server and client are as follows:
[root@test1 local]# rpm -ivh MySQL-server-5.2.0-0.glibc23.i386.rpm[root@test1 local]# rpm -ivh MySQL-client-5.2.0-0.glibc23.i386.rpm
On the server side, to test whether the installation is successful, you can run netstat to check whether the MySQL port is open. The default port is 3306 , the command is as follows:
[root@test1 local]# netstat -nat
Start
After the MySQL installation is completed, the startup file mysql is in the /etc/init.d directory Next, when you need to start, run the following command:
[root@test1 init.d]# /etc/init.d/mysql start
Stop and restart
Note: The commands may be different due to different versions. Only this version is listed here. For other versions of the command, please ask Du Niang.
[root@test1 local]# service mysqld stop[root@test1 local]# service mysqld restart
Several important directories
After MySQL is installed, unlike SQL server, which is installed in a directory by default, its database files , configuration files and command files are in different directories. Here are several directories: 1. Database directory
/etc/lib/mysql/
2. Configuration file
/usr/share/mysql(mysql.server命令及配置文件)
3. Related commands
/usr/bin(mysqladmin、mysqldump等命令)
4. Startup script
/etc/rc.d/init.d/
Change login password
MySQL does not have a password by default. The importance of adding a password after installation is self-evident. 1. Command
usr/bin/mysqladmin -u root password \'new-password'\
Format: mysqladmin -u username -p old password password new password 2. Example (add password to root 123456):
[root@test1 local]# usr/bin/mysqladmin -u root password 123456
Note: because root does not have a password at the beginning , so -p old password can be omitted.
Database Backup and Recovery
1. Backup the database
mysqldump –user=root –password=root密码 –lock-all-tables 数据库名 > 备份文件.sql
2.Restore the database
mysql -u root –password=root密码 数据库名
The above is the detailed content of What are the basic methods of using MySQL?. For more information, please follow other related articles on the PHP Chinese website!