-
Windows:
-
启动:
cd c:/mysql/bin mysqld --console
-
关闭:
cd c:/mysql/bin mysqladmin -uroot shutdown
-
-
Linux:
-
检查MySQL服务器是否启动:
ps -ef | grep mysqld
-
关闭目前运行的 MySQL 服务器:
root@host# cd /usr/bin ./mysqladmin -u root -p shutdown Enter password: ******
-
-
MySQL用户设置:
-
添加用户:
- 以下为添加用户的的实例,用户名为guest,密码为guest123,并授权用户可进行 SELECT, INSERT 和 UPDATE操作权限:
mysql> use mysql; Database changed mysql> INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'guest', PASSWORD('guest123'), 'Y', 'Y', 'Y'); Query OK, 1 row affected (0.20 sec) mysql> FLUSH PRIVILEGES; Query OK, 1 row affected (0.01 sec) mysql> SELECT host, user, password FROM user WHERE user = 'guest';
- 命令会给指定数据库TUTORIALS添加用户 zara ,密码为 zara123
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP -> ON TUTORIALS.* -> TO 'zara'@'localhost' -> IDENTIFIED BY 'zara123';
-
-
/etc/my.cnf文件配置:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
-
管理MySQL的命令:
- USE *数据库名* :
选择要操作的Mysql数据库,使用该命令后所有Mysql命令都只针对该数据库
mysql> use RUNOOB; Database changed
- SHOW DATABASES:
列出 MySQL 数据库管理系统的数据库列表
mysql> SHOW DATABASES;
- SHOW TABLES:
…
一、MySQL管理
最新推荐文章于 2024-06-20 17:02:31 发布