MySQL Common commands

Source: Internet
Author: User

Alter user ' root ' @ ' localhost ' identified by ' root ';

mysql> flush Privileges;

Show variables like ' version% ';

#使用grant方式创建一个新帐户fred, and set the password

Grant usage on *. * to ' fred ' @ ' localhost ' identified by ' Fred ';

#查看刚刚创建的账户

Select Host,user,password from Mysql.user where user= ' Fred ';

#使用set password Way to change your account password

Set password for ' Fred ' @ ' localhost ' =password (' passwd ');

#刷新权限

#flush privileges;

change user name:

Update user set user= "DNS" where user= "root";

View Database

Show databases

Select Database

mysql> use MySQL; Select Database

Set character sets

Set names ' GBK ';

#查询数据库中的表

Show tables;

#查看表结构

DESC test;

#显示数据库版本

Select version ();

#显示当前时间

Select Current_date;

#将查询出的数据导入文件

SELECT * from user to outfile "/etc/test.txt" Fields terminated by ",";

#查看数据库状态

mysql> status;

#导入SQL文件

Source/etc/mysql.sql;

Modify MySQL user password

(1) does not require root user to use Mysqladmin

mysqladmin-u user-p Password Password

(2) requires root user to use update or set

UPDATE user SET Password=password (' 123456 ') WHERE user= ' root ';
FLUSH privileges;

SET PASSWORD for Root=password (' 123456 ');

MySQL Common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.