Mysql的一些常用命令
自定义Mysql启动命令
/usr/local/mysql/bin/mysqld –defaults-extra-file=/usr/local/mysql/my.cnf –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –user=mysql –log-error=/usr/local/mysql/data/localhost.localdomain.err –pid-file=/usr/local/mysql/data/localhost.localdomain.pid –socket=/tmp/mysql.sock –port=3306
通过定义里面的参数,可以在一个机子上启动多个Mysql实例在不同的端口
CREATE USER ‘username’@’%’ IDENTIFIED BY ‘password’;
创建用户,%代表可以来自任何主机,如果是本机,可以写localhost
GRANT ALL PRIVILEGES ON * . * TO ‘username’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0
给用户赋所有权限,也可以根据需要,赋特定的权限
导出一个库
mysql/bin/mysqldump -u user -p password dbname > /full/path/dbname.sql
导入一个库
mysql -u user -p password –default-character-set=utf8 dbname < /full/path/dbname.sql
--default-character-set是指定数据库编码