Check that the MySQL service has started and has started
This command is not in the environment path.
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] ~]# export path= $PATH:/usr/local/mysql/bin/Add the command to the path, but it does not take effect permanently. To be permanently active, put the statement under/etc/profile
[[email protected] ~]# Source/etc/profile effective
-U specify user,-p specify password
[[email protected] ~]# mysqladmin-uroot password ' aminglinux.1 ' Set root password
Warning:using a password on the command line interface can is insecure.
[[email protected] ~]# mysql-uroot no password-P will error
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
[Email protected] ~]# mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 5
Server version:5.6.36 MySQL Community Server (GPL)
Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql>
So how to change the password (under the condition of the known root password)
What to do if you forget the root password
1. Change configuration file, add skip-grant, ignore authorization
2. Restart MySQL
You can log in directly.
3 Changing the user table, updating the password
4. Change the previous configuration my.cnf back and restart the service
The following-p is used to specify the bound port of the remote host MySQL, by default 3306,-h is used to specify the IP of the remote host
Using the socket to connect MySQL, not TCP/IP, is only suitable for use in native
Execute SQL statement when connecting
View the fields in the table
Mysql> Show CREATE TABLE user\g; See how the watch was built.
View the database that you are using
Create a database DB1
View current version
View queues
13.1 Settings Change root password 13.2 Connect MySQL 13.3 mysql common command