建库 create database discuz character set utf8 collate utf8_bin; 建用户 grant all privileges on wordpress.* to wordpress@localhost identified by 'wordpress'; grant create,select,insert,update,delete,drop on discuz.* to discuz@192.168.2.195 identified by 'discuz'; revoke create on wordpress.* from wordpress@localhost; 查看版本 select version(); 查看所有用户 select user,host from user; 查看用户授权 show grants for root@localhost; 删除空用户名用户 drop user ""@localhost; 修改root用户密码 mysqladmin -uroot password "123456" mysqladmin -uroot -p123456 password "root" 刷新权限 flush privileges; show create table pre_home_poke\G; 查看建表词句 show status 查看mysql状态 show processlist; 查看mysql队列 truncate table tablename; 清空表 /root/.mysql_history mysql历史执行语句
ln -s /dev/null /root/.mysql_history 不记录历史语句
多实例本地登录 mysql -uroot -p123456 -S /tmp/3307/mysql.sock 多实例远程登录 mysql -uroot -p123456 -h 192.168.1.10 -P 3307
查询
mysql -uroot -p123456 -e 'select * from python.userinfo'