重启Mysql服务
(cnetOS 环境)
# /etc/init.d/mysql restart
# /etc/init.d/mysql stop
# /etc/init.d/mysql start
创建mysql用户
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
设置root密码
(cnetOS 环境)
# mysql -u root -p
mysql> use mysql;
mysql> update user set password=password('aaa') where user='root';
mysql> flush privileges;
mysql> exit
(mac环境)
bogon:bin mrs.liang$ cd /usr/local/mysql/bin/
bogon:bin mrs.liang$ sudo su
sh-3.2# ./mysqld_safe --skip-grant-tables &
sh-3.2# ./mysql
mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR 'root'@'localhost' = 'youpassword';
设置外部访问
# mysql -u root -proot
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES ; //刷新权限
卸载mysql
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*