天天看點

mysql 相關

########################################################

相看表字元集和排序規則 

show full columns from ts_user;

##################################################################

忘記ROOT 密碼

vi /etc/my.cnf

加入 skip-grant-tables

#servie mysqld restart 

#mysql 

>use mysql;

>update user set password = password('123456') where user = 'root'

>flush privileges ;

>quit;

在 /etc/my.cnf   前面加“#”  #skip-grant-tables

mysql -u root -p 123456  

###################################################

mysql 備份

mysqldump -hlocalhost -u root -proot    temp > temp_2011.sql 

恢複

mysqldump -hlocalhost -u root -proot    temp < temp_2011.sql 

-u 和 -p 要不要空格自己 風格,如果有空格回車要求再一次輸入密碼,最好是不要空格(身旁沒人的時候)就一次到位

################### 增加使用者和ROOT權限一樣的###########

有密碼直接 進入 ,沒有MYSQL密碼,通過上面忘記ROOT密碼 進入執行下面語句。

mysql> insert into user set user='rootname',ssl_cipher='',x509_issuer='',x509_subject=''; 

mysql> update user set Host='localhost',select_priv='y', insert_priv='y',update_priv='y', Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y',create_user_priv='y' where user='rootname'; 

mysql> update user set password=password('123456') where user='rootname';

mysql> flush privileges;

繼續閱讀