1. Change the root password

See the mysql start or not, if not start running: / usr/local/mysql56 / bin/mysql

Ps aux | grep mysql or netstat tulnp | grep 3306 running mysql command, will appear:

-bash: mysql: command not found

Mysql will get added to the environment variables: add: temporary PAHT = PATH: / usr/local/mysql56 permanent add/bin: echo “exportPATH = PATH: / usr/local/mysql56 permanent add/bin: Echo “export PATH = PATH: / usr/local/mysql56 permanent add/bin: Echo “exportPATH = PATH: / usr/local/mysql56 / bin” > > / etc/profile. Then run soucre/etc/profile or/etc/profile

Mysql password: specifies the password of the root user

Mysql -uroot password’ new_password

How to change the password: mysqladmin -uroot -p ‘old_password’ password’ new_password’ or use the following method

First, you need to change the configuration file: vim /etc/my.cnf

Sed -i ‘/3306/a\skip-grant’ /etc/my.cnf /etc/init.d/mysqld restart

Then, switch the database: use mysql; Update user set password=password(‘new_password’) where user=’root’; update user set password=password(‘new_password’) where user=’root’; That changed the password back

My.cnf = my.cnf;

Mysql -uroot -p’password’ mysql -h127.0.0.1 -uroot -p’password’ mysql -s/TMP /mysql.sock -uroot -p’password’ mysql -s/TMP /mysql.sock -uroot -p’password’ mysql -uroot -p -e “show databases”

Mysql common commands

Query databases: show databases; Use a library: use database_name; To see how many tables there are: show tables; Table_name: show create table table_name\G; Select user(); Check which library is currently in use: select database(); Check the current database version: select version(); To view parameters that can be defined in the configuration file, run the show variables command. To view the current number of processes: show processList; Or show full the processlist. # this is the most used (that is, to see what is going on in the database)

Create a database: create database db_name; Create table table_name(‘name’ types(length),’name’ type(length),……..)

Create table table_test(id int(10),name char(32),sex int(4));

The first part is complete.

conclusion

If you have any questions, please leave a message to me. Xiaobi will reply to you in time. Thank you very much for your support of open source exclusive website!

If the above article is helpful to you, please give our open source project Diandian star: github.crmeb.net/u/defu!