1. Create an administrative user for the MYSQLD database:To set the root user as an administrator, we should run the following command;
123456
In general, the Mysqladmin directory has been added to $path, if the command is not found, see if the package is installed correctly
Ensure that the Mysql-server and mysql-client two packages have been successfully installed
You can then RPM-QF mysql-client to view the command installed in that directory, add the directory to the $path variable, or use the full path.
The root of this is not a system user, but a database user. You can also take a different user name.
2. Log in to MySQL database
To MySQL database administrator root, password 123456 for example;
Mysql-uroot--uroot-p or #/opt/mysql/bin/mysql-u root-p
If the command is not found, check the path variable, and enter password: Enter the password and return. Then appears:
Mysql>
Now it's time to go to the MySQL admin interface, and be careful to make sure MySQL is up and running before landing.
3, Operation command:
In the MySQL database, each operation is a command, the end of the number. If you forget to add, use \c to exit.
Show existing Databases:
mysql> show databases;
4, creating and deleting databasesTo create a database:
mysql> CREATE DATABASE [DB name]; such as: MySQL> CREATE database CRC;
To delete a database:
mysql> drop DATABASE [db name]; such as: MySQL> drop database CRC;
5, Operation databaseThe first is to specify a database as the current database, using the use command,
mysql> use [database name];
6, backing up the database
# mysqldump-u root-p Linux >/root/linux.sql
then enter the password enter Password:
The first backup database is to be backed up as a database administrator (not a system administrator); second: The Backup destination is/root, and the backup file name is Linux.sql. In fact, the location and file name of the backup, according to their own situation to decide. The file name can be taken by itself, the path can be arranged on its own, for example, I want to back up the Linux database to/home/beinan, the database file name islocalhost. sql, so you should enter the following command.
-U root-p Linux >/home/beinan/localhost. sql
7. Import the backed-up database into the databaseFor example, if we want to import the Linuxsir031130.sql this backup in the/home/beinan directory into a database named Linux, you should do the following:
# mysql-u Root-p Linux
Enter Password: Enter the password here
8, other common MySQL commands view status:Mysql>show status;
To view a process:Mysql>show processlist;
To view a table, you should first specify a database as the current database, such as a database called Linux; show tables;mysql> useLinux; MySQL> show tables; Set (0.00 sec)
some additions:A few common MySQL-related management commandsmysql command: Basic text, display and use of MySQL database. The previous usage has been simply mentioned, such as login. The mysqladmin command, which is used to create and maintain MySQL database commands, has been briefly mentioned; Isamchk is a database file that is used to repair, inspect, and optimize the. ism suffix ,mysqldump is used to back up the database, as explained in the previous brief; Myisamchk the database file used to repair the. myi suffix;
For example, we want to check the database named Linux. myi database table If there is a problem, you should use the following command; /opt/mysql/share/mysql.server Stop /opt/mysql/bin/myisamchk/opt/mysql/var/linux/* . MYI
The above command means to check all the. myi files, the directory of the database in the/opt/mysql/var/linux/directory if there is a problem, you should use the-R parameter to fix#/opt/mysql/bin/myisamchk-r/opt/mysql/var/linux/*. MYI #/opt/mysql/bin/mysqlshow-u Root-p [database name]
Mysqlshow command: Displays the database and table selected by the userMySQL basic command under Linux