首页 > 代码库 > Mysql学习

Mysql学习

1.登录mysql,进入mysql bin 目录:

mysql -u root -p

回车后提示输入密码,刚创建完数据库后,root 密码为空,直接回车登录;也可以再登录时指定数据:

mysql -u root dbname -p

2.修改root 用户密码:
方法1:

mysql> set password for ‘root‘@‘localhost‘=password(‘sywu‘);

方法2,直接更新user 表:

mysql> use mysql
Database changed
mysql> update user set password=password(‘sywu‘) where user=‘root‘;
Query OK, 2 rows affected (0.00 sec)
Rows matched: 3  Changed: 2  Warnings: 0

3.查看数据库:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cdcol              |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
| webauth            |
| wordpress          |
+--------------------+
8 rows in set (0.00 sec)
4.连接某个数据库:
mysql> use mysql;
Database changed

Mysql学习