ubunt下的mysql安裝

設置root權限(ubuntu)

爲root設置一個root密碼就行了: $ sudopasswd root

su root

1、安裝mysql:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql(用於連接php和mysql)

查看mysql是否運行
ps aux | grep mysql

啓動命令
/etc/init.d/mysql start

2.刪除mysql
按順序執行以下命令
sudo apt-get autoremove --purge mysql-server-5.0
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common 

清理殘留數據
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P


----------------------修改密碼--------------------------

1. 先停止mysql


  1. sudo service mysql stop
2. 運行mysqld_safe

  1. sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking
3. 命令行下進入數據庫

  1. mysql -u root mysql
4. 修改user表:root用戶密碼

  1. update user set password=PASSWORD('newpassword') where user='root';
5.修改user表:root權限(Grant_priv),其他權限類似

  1. select * from user where user='root';
  2. update user set Grant_priv='Y' where user='root';
6. 停止mysqld_safe,重啓mysql(可能不安全)

  1. kill -9 mysqld_safe_pid
  2. pkill mysql
  3. service mysql start
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章