本地用户连接mysql设置如下:

GRANT ALL on database.* to ‘user’@’localhost’ identified by ‘paswword’;
如果想增加用户去任何机器连接,设置如下:
GRANT ALL on database.* to ‘user’@'[……]

Read more

当在服务器远程连接mysql服务器的时候,登录后编码方式latin1;接着我在mysql命令窗口修改为utf-8后,再次远程登录,编码方式依然为latin1;

#mysql -h 192.168.1.114 -uroot -p123456

mysql> show variables like '%character%'
    -> ;
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | latin1                           | 
| character_set_connection | latin1                           | 
| character_set_database   | utf8                             | 
| character_set_filesystem | binary                           | 
| character_set_results    | latin1                           | 
| character_set_server     | utf8                             | 
| character_set_system     | utf8                             | 
| character_sets_dir       | /usr/local/mysql/share/charsets/ | 
+--------------------------+----------------------------------+

mysql>select * from table;
id	name
1 ???
2	android
12 wap 

[……]

Read more

从其他服务器导入的Mysql数据库,包含存储过程,程序中访问的用户若与当初存储过程的定义者不同,则会导致无法执行存储过程,使用如下命令可以修改存储过程定义者为需要的账户。例:将td数据库的所有存储过程的定义者修改为root@%

update mysql.proc set DEFINER='ro[......]

Read more

查看Mysql编码如下:

mysql> show variables like "character%";                   
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     | 
| character_set_connection | latin1                     | 
| character_set_database   | utf8                       | 
| character_set_filesystem | binary                     | 
| character_set_results    | latin1                     | 
| character_set_server     | utf8                       | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

发现编码方式为latin1,这种方式对于插入中文字符则会显示乱码,通常我们需要将其改为utf8,若使其临时生效可以这样设置:
[……]

Read more