In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces to you to change the root password to achieve connection MySQL and common commands, the contents of the article are carefully selected and edited by the author, with a certain pertinence, for everyone's reference significance is still relatively great, the following with the author to understand by changing the root password to achieve connection MySQL and commonly used commands.
Set to change the root password
First of all, check to see if mysql is started.
Ps aux | grep mysql
If it doesn't start, start mysql first.
/ etc/init.d/mysqld start
First add the mysql directory to the environment variable
Export PATH=$PATH:/usr/local/mysql/bin/
Then write the command to the configuration file and take effect permanently
Vim / etc/profile
Add the following to the file
Export PATH=$PATH:/usr/local/mysql/bin/
Set mysql password
Mysqladmin-uroot password 'windows1.1'
Set the password to windows1.1
Change the mysql password
Mysqladmin-uroot-paired windows 1.1 'password' windows1.2'
What if I forget my MySQL password?
Edit MySQL profile
Vim / etc/my.cnf
Add the following under [masqld] (to ignore authorization)
Skip-grand
After changing the configuration file, you need to restart the startup service to take effect
/ etc/init.d/mysqld restart
Log in to MySQL after restarting the service, and you can log in without a password.
Mysql-uroot
Switch to the mysql library
Use mysql
Then you can change the password to windows1.3 here.
Update user set password=password ('windows1.3') where user='root'
Exit mysql after changing the password, and then delete the skip-grand in the my.cnf in the configuration file
Then restart the MySQL service again to complete the password change
Connect MySQL
The mysql that connects to this machine, u specifies the user name, p specifies the password
Mysql-uroot-p123456
Connect remote MySQL,h specifies the IP of the remote machine, uppercase P specifies the port
Mysql-uroot-p123456-h292.168.71.133-P3306
Connect using sock, uppercase S only as sock
Mysql-uroot-p123456-S/tmp/mysql.sock
Connect mysql to operate, and-e is followed by a command, which is generally used in shell scripts
Mysql-uroot-p123456-e "show databases"
Commands commonly used in MySQL
Query library
Show databases
Switch the library, here is the demonstration to switch to the MySQL library
Use mysql
Check the table in the library
Show tables
Check the fields in the table. Here is a demonstration to view the fields in the user table.
Desc user
View the table creation statement. Here is a demonstration to view the user table. The uppercase G is displayed vertically.
Show create table user\ G
View current user
Select user ()
View the database currently in use
Select database ()
Create a library, which is shown here to create a library called testdb1
Create database db1
Create a table. What is shown here is to create a table called T1. The first field is called id and is an integer with a maximum length of 4. 0. The second field, called name, is a character with a maximum length of 40
Create table T1 (idint (4), namechar (40))
View the current database version
Select version ()
View database status
Show status
View each parameter
Show variables; show variables like 'max_connect%'
Modify parameters
Set global max_connect_errors=1000
View queue show processlist; show full processlist
Show processlist; show full processlist
After reading the above about connecting to MySQL and common commands by changing the root password, many readers must have some understanding. If you need more industry knowledge and information, you can continue to follow our industry information column.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.