欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql 命令

程序员文章站 2022-06-06 09:55:26
...

1 有环境变量可以省略这个 cd D:\Program\MySQL\MySQL Server 5.5\binD:\Program\MySQL\MySQL Server 5.5\binmysql -uroot -p 2 建用户并授权 GRANT ALL PRIVILEGES ON *.* TO user@localhost IDENTIFIED BY pwd WITH GRANT OPTION;GRANT ALL PRIVILEGES ON


1 有环境变量可以省略这个

cd D:\Program\MySQL\MySQL Server 5.5\bin
D:\Program\MySQL\MySQL Server 5.5\bin>mysql -uroot -p


2 建用户并授权

GRANT ALL PRIVILEGES ON *.* TO user@localhost IDENTIFIED BY 'pwd' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO user@'%' IDENTIFIED BY 'pwd' WITH GRANT OPTION;#话说密码里有\,执行这句的时候要在前边加\\,变成一共3个斜杠
FLUSH PRIVILEGES;


3建库删库

CREATE DATABASE test2 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
DROP DATABASE test2;


4导入导出

mysqldump -uroot -proot dbname>D:\1.sql
mysql -uroot -proot --default-character-set=utf8 dbname

5 查看mysql配置

ps aux | grep mysqld
root      5036  0.0  0.0  61220   748 pts/2    S+   17:21   0:00 grep mysqld
root     25970  0.0  0.0  64020  1292 ?        S    Sep15   0:00 /bin/sh /usr/bin/mysqld_safe --defaults-file=/mysqldata/mysql3306/3306.cnf
nobody   26729  0.3  1.9 1873068 1316752 ?     Sl   Sep15  10:20 /usr/sbin/mysqld --defaults-file=/mysqldata/mysql3306/3306.cnf --basedir=/usr --datadir=/mysqldata/mysql3306 --plugin-dir=/usr/lib64/mysql/plugin --user=nobody --log-error=/mysqldata/mysql3306/slave.err --open-files-limit=8192 --pid-file=/mysqldata/mysql3306/slave.pid --socket=/tmp/mysql3306.sock --port=3306

6 重启 停止 启动 状态
service mysqld stop/start/restart/status
%mysqld_path%/mysqld stop/start/restart/status



错误1

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

mysql -uroot -p --socket=/tmp/mysql3306.sock

错误2

Please read "Security" div of the manual to find out how to run mysqld as root!

mysql -uroot -p --user==root