MySQL contains the [client] and [mysqld] sections in the configuration file, and MySQL has its own client commands and server-side commands. The following is a brief introduction.
MySQL contains the [client] and [mysqld] sections in the configuration file, and MySQL has its own client commands and server-side commands. The following is a brief introduction.
MySQL contains the [client] and [mysqld] sections in the configuration file, and MySQL has its own client commands and server-side commands. The following is a brief introduction.
① If the administrator sets a logon password for the MySQL Login User but does not want to enter the password for each login, you can create a hidden file under the user's home directory. The file name is. my. cnf. The following uses the root user as an example:
Vi/root/./my. cnf
[Client]
User = root
Password = RedHat
Host = localhost
After saving and exiting, MySQL will automatically read the configuration file the next time you log on, so that you can log on without entering the user name and password each time.
② You can specify the default database after logon before Logon:
Mysql-D mysql // After logging on, the default database is mysql.
After logging in, you can check whether you are in the mysql database.
Select database ();
③ The written data script file can be directly imported into the database. There are two methods: direct input redirection and Client Command import.
First, create a database script.
Vi/root/mysql. sh
Create database hello;
USE HELLO
Create table stu (id int, name varchar (30 ));
Insert into stu (ID, NAME) VALUES ('1', 'mysql ');
Mysql </root/mysql. sh // The data has been imported successfully. You can view ------ à input redirection method.
Mysql>
Source/root/mysql. sh
. \/Root/mysql. sh
④ Client commands:
Mysql>
\ C: If the command is not used before the command Terminator is entered, the entry command is terminated in advance and the command is not executed.
\ D: Set the command Terminator. The default command terminator in mysql is a semicolon.
\ G: Execute the command no matter what the command Terminator is.
\ G: Execute the command no matter what the command Terminator is, and display the execution result in a vertical bar (it looks intuitive ).
\ Q: Exit mysql
\! Shell command: execute shell command \ in mysql \! Ll/root // view the price information under root.
⑤ Server commands
Mysqladmin-uroot-h localhost password 'redhat' // The password option changes the user password.
Mysqladmin version // view the mysql running status and version information.
Mysqladmin status // view the mysql running status.
Mysqladmin extend-status // view the status variable information.
Mysqladmin variables // view the server variables.
Mysqladmin flush-privileges // Let mysqld re-read the authorization table ==== function is equivalent to mysqladminreload
Mysqladmin flush-status // reset most server status variables.
Mysqladmin processlist // view the list of processes in progress.
Mysqladmin refresh // reset host information and rolling relay and level-2 log information. === Mysqladmin flush-logs + mysqladmin flush-hosts.
Mysqladmin start-slave // start the slave Server replication thread.
Mysqladmin stop-slave // stop the replication thread.
Ps: Server variables are classified into global variables and session variables. After the global variables are defined, they take effect immediately and use them with all sessions. The session variable is only valid for the current session.
View mysql global variables
Mysql>
Show global variables;
Mysql>
Show session variables // or show variables
When the server variable is called
Select @ global. SQL _mode
Select @ SQL _mode
Set global SQL _mode = "strict_all_tables"
Set session SQL _mode = "strict_all_tables"
6. View table attribute information
Show talbes status like 'user' here like fuzzy match can be used.
Write it first.
What do you know about MySQL passwords?
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
MySQL-5.5.38 universal binary Installation