mac下修改mysql-root密碼-各種許可權問題解決,macmysql-root

來源:互聯網
上載者:User

mac下修改mysql-root密碼-各種許可權問題解決,macmysql-root

官方資料:http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix

還有一個值得參考的mysql安裝,與python-mysql安裝部落格http://hearrain.com/2011/01/498


據官方文檔說,

For example, if you run the server using the mysql login account, you should log in as mysql before using the instructions. Alternatively, you can log in as root, but in this case you must start mysqld with the --user=mysql option. If you start the server as root without using --user=mysql, the server may create root-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups.

如果在安裝完mysql後,當你用root登入的時候,必須加上--user=mysql,否則的話,伺服器會自動建立root-owned檔案,這些就會導致許可權的問題


我之前就是因為直接登入了,然後root密碼無修改許可權,各種無許可權


解決的辦法就是

shell> kill `cat /mysql-data-directory/host_name.pid`
mysql-data-directory   的路徑一般是 /usr/local/mysql/data下的包含你的電腦名稱的以pid結尾的檔案


UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';FLUSH PRIVILEGES;
結束進程之後,把上面的兩句話放到一個檔案中例如update_passwd,該檔案在/usr/local/下


shell> mysqld_safe --init-file=/home/me/mysql-init &

然後sudo su進入root許可權,進入mysql下bin輸入以上命令,結束後(我的好像沒有結束,就另開了一個terminal),

進入mysql命令列下

UPDATE mysql.user SET Password=PASSWORD('MyNewPass')    ->                   WHERE User='root';

然後再進入就ok了






MAC OS X1082系統怎更改mysql密碼?

同樣也是10.8.2,安裝之後預設是沒有密碼的。。。現在處於很坑爹狀態。。。。
 
[轉載]怎更改MYSQL的ROOT預設空密碼

cmd下切換到 mysql 安裝目錄例d:/mysql/bin前提:mysql使用者root密碼為空白.輸入mysql -u root mysqlmysql> 狀態下輸入 update user set password=password('新密碼') where user='root';回顯Query OK, 0 rows affected (0.00 sec)Rows matched: 2 Changed: 0 Warnings: 0mysql> 狀態下輸入 FLUSH PRIVILEGES;回顯Query OK, 0 rows affected (0.00 sec)mysql> 狀態下輸入 quit退出sql注意每個命令後都要加上一個分號 ";"mysql 才開始執行該行命令而第二個指令會讓已載入記憶體的 mysql 系統資料庫更新重起mysql .在更新 root 密碼後,以後要與 MySQL 串連的方法為:
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.