The following articles mainly describe how to implement the basic usage of MySQL Databases in linux. The following describes the specific operations in the article, if you are interested in the actual operations, I hope the following articles will help you in this regard. 1] How to Create a MySQL (the best combination with PHP) d database management user? Quantity
The following articles mainly describe how to implement the basic usage of MySQL Databases in linux. The following describes the specific operations in the article, if you are interested in the actual operations, I hope the following articles will help you in this regard. 1] How to Create a MySQL (the best combination with PHP) d database management user? Quantity
The following articles mainly describe how to implement the basic usage of MySQL Databases in linux. The following describes the specific operations in the article, if you are interested in the actual operations, I hope the following articles will help you in this regard.
1] How to Create a MySQL (the best combination with PHP) d database management user?
After the database is installed, we should create a management account for the MySQL (best combination with PHP) database. To set the root user as the administrator, we should run the following command;
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/MySQL database (the best combination with PHP) admin-u root password 123456
[Root @ linuxsir01 root] #
Through the above command, we can know that the administrator of the MySQL database (the best combination with PHP) is root, and the password is 123456.
2] how to access the MySQL database (the best combination with PHP?
Take MySQL (the best combination with PHP) as the database administrator root. The password is 123456;
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP)-uroot-p123456
After the preceding command is output, the following prompt is displayed;
Welcome to the MySQL (the best combination with PHP) monitor. Commands end with; or \ g.
Your MySQL (best combination with PHP) connection id is 6 to server version: 3.23.58
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
MySQL (the best combination with PHP)>
Note: When operating these commands, you should open the MySQL database (the best combination with PHP) d server. These new siblings have long known about it :)
3] how to operate commands in a database?
I think this is the best combination of MySQL (and PHP) manuals, I mainly want to pay attention to a few points. In fact, I cannot have several commands. If you want to learn it, it is not difficult. If you have operated MySQL in windows (the best combination with PHP), it is actually the same here, mySQL (the best combination with PHP) is a cross-platform database with the same usage.
In the MySQL (best combination with PHP) database, every command operated is at the end of the ";". Some new beginners may have forgotten to enter it, the result cannot be returned. :):)
1] Check which databases are available in MySQL (the best combination of PHP and MySQL?
Code:
MySQL (the best combination with PHP)> show databases; + ---------- + | Database | + ---------- + | MySQL (the best combination with PHP) | test | + ---------- + 2 rows in set (0.00 sec) MySQL (the best combination with PHP)> installed in MySQL (the best combination with PHP, after the Administrator is set up, go to the system for the first time. Run the show databases command to view the Database List and find two databases, MySQL (the best combination with PHP) and test, this is self-built by the system and is intended for practice.
4] how to create and delete a database?
For example, to create a database named linux, run the following command:
MySQL database (the best combination with PHP)> create database [database name];
Therefore, we should run the following command to create a database named linux
MySQL (the best combination with PHP)> create database linux;
Query OK, 1 row affected (0.00 sec)
Is it built ?? It must have been built, because there are OK :)
Check whether there is a linux database?
Code:
MySQL (the best combination with PHP)> show databases; + ---------- + | Database | + ---------- + | linux | MySQL (the best combination with PHP) | test | + ---------- + 3 rows in set (0.00 sec) MySQL (the best combination with PHP)> How do we delete a database ??
MySQL (best combination with PHP)> drop database [database name];
For example, to delete the created linux database, use the following command;
MySQL (the best combination with PHP)> drop database linux;
Query OK, 0 rows affected (0.00 sec)
Is it deleted ??
Code:
MySQL (the best combination with PHP)> show databases; + ---------- + | Database | + ---------- + | MySQL Database (the best combination with PHP) | test | + ---------- + 2 rows in set (0.00 sec) MySQL (the best combination with PHP)>
5] how to operate a database?
This is a lot of problems. I suggest you take a look at the MySQL (the best combination with PHP) manual. There are too many things in it. To operate a database, you must first specify a database as the current database. use the use command
MySQL (the best combination with PHP)> use [database];
For example, if I want to specify the database linux as the current database, it should be
MySQL (the best combination with PHP)> use linux;
Database changed
MySQL (the best combination with PHP)>
6] how to back up the database ??
For example, to back up an existing linux database in MySQL (the best combination of PHP and MySQL), run MySQL (the best combination of PHP and MySQL) dump.
The command format is as follows:
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP) dump-uroot-p linux>/root/linux. SQL
Enter password: Enter the Database password here
Through the above command, we need to understand two things: first, back up the database as a database administrator; second, the backup destination is/root, and the backup file name is linux. SQL. In fact, the backup location and file name are determined based on your own situation. The file name can be retrieved by yourself, or the path can be arranged by yourself;
For example, if I want to back up a linux database to/home/beinan and the database name is linuxsir031130. SQL, enter the following command.
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP) dump-uroot-p linux>/home/beinan/linuxsir031130. SQL
Enter password: Enter the database password of the database administrator root.
In this way, we can find the linux database backup file linuxsir031130. SQL IN THE/home/beinan directory (the best combination with PHP ).
To sum up, we must learn to make changes when learning. :):)
6]How to import the backup database to the database?
First, we need to operate on the above processes, such as adding a Database Administrator (if you have not added a MySQL database administrator (the best combination with PHP), creating a database, and so on.
For example, to back up linuxsir031130. SQL IN THE/home/beinan directory and import it to a database named linux, perform the following operations;
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/MySQL database (the best combination with PHP) -uroot-p linux
Enter password: Enter the password here
If the machine is good, the database is relatively small, just a few minutes.
7] other commonly used MySQL commands (the best combination with PHP;
View status
MySQL (the best combination with PHP)> show status;
View Processes
Code:
MySQL (the best combination with PHP)> show processlist; + ---- + ------ + ----------- + ------ + --------- + ------ + ------- + ------------------ + | Id | User | Host | db | Command | Time | State | Info | + ---- + ------ + ----------- + ------ + --------- + ------ + ------- + ---------------- + | 16 | root | localhost | NULL | Query | 0 | NULL | show processlist | + ---- + ------ + ----------- + ------ + --------- + ------ + ------- + ------------------ + 1 row in set (0.00 sec) mySQL (the best combination with PHP)> to view a table, you should first specify a database as the current database; for example, a database named linux;
MySQL (the best combination with PHP)> use linux;
MySQL (the best combination with PHP)> show tables;
Empty set (0.00 sec)
MySQL (the best combination with PHP)>
7] a supplement to Common commands of MySQL (the best combination with PHP) databases;
Several common management commands related to MySQL (the best combination with PHP)
MySQL (the best combination with PHP) command: displays and uses the MySQL (the best combination with PHP) database in basic text. I have mentioned the usage in the previous section, such as logon.
The admin COMMAND for MySQL (the best combination with PHP) is used to create and maintain the MySQL (the best combination with PHP) database commands, which have been briefly mentioned earlier;
Isamchk is a database file used to repair, check, and optimize the. ism suffix;
MySQL (the best combination with PHP) dump is used to back up the database, which has been briefly described earlier;
Myisamchk is used to fix database files with the. myi suffix;
For example, to check whether there is a problem with the database named linux. myi database table, use the following command;
Stop MySQL (the best combination with PHP) d server
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/share/MySQL database (the best combination with PHP). server stop
Then execute
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/myisamchk/opt/MySQL (the best combination with PHP) /var/linux /*. MYI
The above command means to check all. myi files. The database directory is in/opt/MySQL (the best combination with PHP)/var/linux/directory.
If any problem occurs, use the-r parameter to fix it.
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/myisamchk-r/opt/MySQL (the best combination with PHP) /var/linux /*. MYI
8]MySQL (best combination with PHP) show command: displays the database and table selected by the user
[Root @ linuxsir01 root] #/opt/MySQL (the best combination with PHP)/bin/MySQL (the best combination with PHP) show-uroot-p [database name]
For example, if I want to view a database named linux, it should be:
[Root @ linuxsir01 root] #/opt/MySQL database (the best combination with PHP)/bin/MySQL (the best combination with PHP) show-uroot-p linux