Home > Database > Mysql Tutorial > What are the basic methods of using MySQL?

What are the basic methods of using MySQL?

WBOY
Release: 2023-05-26 17:09:26
forward
1591 people have browsed it

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.

What are the basic methods of using MySQL?

MySQL installation

Download the MySQL installation file

The following two files are required to install MySQL. All can be downloaded from the official website.

MySQL installation

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
Copy after login

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
Copy after login

Start and stop MySQL

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
Copy after login

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
Copy after login

MySQL configuration

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/
Copy after login

2. Configuration file

/usr/share/mysql(mysql.server命令及配置文件)
Copy after login

3. Related commands

/usr/bin(mysqladmin、mysqldump等命令)
Copy after login

4. Startup script

/etc/rc.d/init.d/
Copy after login

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'\
Copy after login

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
Copy after login

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
Copy after login

2.Restore the database

mysql -u root –password=root密码 数据库名
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template