Home  >  Article  >  Database  >  mysql 命令

mysql 命令

WBOY
WBOYOriginal
2016-06-07 15:35:081110browse

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<d:><br>
<br>
<p><strong>5 查看mysql配置</strong></p>
<pre class="brush:php;toolbar:false">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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn