First, MySQL settings change the root password
1. Add MySQL to Path:
Export path= $PATH:/usr/local/mysql/bin
Let the variable take effect permanently:
Vim/etc/profile put the above command into the end and let it take effect immediately: source/etc/profile
2. Create a password
1> Enter mysql:mysql-uroot-p (specify password), use Quil to exit MySQL
2> Create password: mysqladmin-uroot password "123"
3> Change Password: mysqladmin-uroot-p "123" password "321"
4> do not know how to change the root password (reset password): vi/etc/my.cnf plus one line: skip-grant (Ignore permissions), and then restart the MySQL service:/etc/init.d/mysqld restart
5> then you can go straight to MySQL, and we need to change a table:
Enter a database: use MySQL; (Switch library),
Enter the table where the user and password are stored: SELECT * from user;
Modify table: Update user set Password=password (' 123 ') where user= ' root ';
6, back to MySQL, and then/etc/profile added to the line to remove, save to restart the service.
Second, connect MySQL
1. Enter the local mysql:mysql-uroot-p123
2. Connecting Remote mysql:mysql-uroot-p123-h127.0.0.1-p3306
3. Connect MySQL with socket (only for this machine): Mysql-uroot-p123-s/tmp/mysql.sock
4, after connecting MySQL to operate some commands: MYSQL-UROOT-P123-E "show Databases"//list all databases
Iii. common commands for MySQL
1. View all databases: show databases;
2, switch the library: use MySQL;
3, list the table in the library: show tables; Desc user; Delete a table: drop table test;
4. View the fields inside the table:
5, view the Build Table statement show create TABLE tb_name\g; G Vertical Row Display
6. View Current User: Select User ();
7. View the currently used database select Databsase ();
8, create database db1;
9, create the table use DB1; CREATE TABLE T1 ( id
int (4), name
char (40));
10. View current database version select version ();
11. Check the status of the database. Show status;
12, check the parameters show variables; Show variables like ' max_connect% ';
13, modify the parameters set global max_connect_errors=1000;
14, check the queue show processlist; Show full processlist;
MYSQLYMLF set root password, connect and some common commands