MySQL client login(10)

Client login and
interactive login to
MySQL –h –u –p –P DBNAME –e “sql”
-u is the meaning of user, generally can be written directly as –uroot or –u MySQL
-h refers to the meaning of host IP –h192.168.1. 120. Set the user to be able to access remotely.
-p means password, you can write the password directly -pP@ssw0rd or don't write password for security -p
-P means port, for multi-instance mylsq, you can choose port login -p3306
DNNAME refers to the database name, you can write the database name directly
-e is used to execute statements
[root@MySQL ~]# MySQL -h 192.168.1.120 -uroot -pP@ssw0rd -P3306 test001
MySQL client login(10)
non-interactive use
-e
[root@ MySQL ~]# MySQL -h 192.168.1.120 -uroot -pP@ssw0rd -P3306 -e "show databases;" >>/root/shell/test.sql
MySQL client login(10)
Other
; and \g means that a sentence is written
MySQL client login(10)
\h or \? is the representative to check and help the
MySQL client login(10)
MySQL client login(10)
client login and forget the password


Edit the my.cnf file in MySQL 5.7.6 or later,
regardless of source code compilation, binary compilation, or yum installation and rpm installation,
add
[MySQLd]
skip-grant-tables
[root@MySQLgeneric ~]# vi /etc/my.cnf
MySQL client login(10)
restart MySQL service
[ root@MySQLsource ~]# service MySQLd restart
MySQL client login(10)
Log in to the MySQL database
[root@MySQLsource ~]# MySQL
MySQL client login(10)
view MySQL permissions content
MySQL> desc MySQL.user;
MySQL client login(10)
MySQL> select user,host,authentication_string from MySQL.user;
MySQL client login(10)
modify password
MySQL> update MySQL .user set authentication_string=password('P@ssw0rd123') where user='root';
MySQL client login(10)
modify back to the my.cnf file and restart the MySQL server
[root@MySQLsource ~]# vi /etc/my.cnf
MySQL client login(10)
MySQL client login(10)
log in to the database
[root@ MySQLsource ~]# MySQL -uroot -pP@ssw0rd123 MySQL
MySQL client login(10)
versions before 5.7.5
MySQL client login(10)

Guess you like

Origin blog.51cto.com/huxiaoqiu/2540063