標籤:style http color os 檔案 io for art
官方資料: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了