grant all on databasename.tablename to 'username'@'xxx.xxx.xxx.xxx' identified by 'complexpassword';
这是基本授权的基本格式,“all”那个位置可以分得更细,“databasename.tablename”这个地方可以使用通配符“*”,“@”后面的地址部分可以使用通配符“%”来限定网段,比如:
grant SELECT,INSERT, UPDATE, DELETE, CREATE, DROP, ALTER on *.* to 'myuser'@'%' identified by 'mypasswd';
grant all on discuz.* to 'username'@'xxx.xxx.xxx.%' identified by 'complexpassword';
grant all on discuz.* to 'username'@'%' identified by 'complexpassword';
flush privileges;//刷新生效
show processlist;//显示哪些线程正在运行
show variables like "max_connections";//显示最大连接数
以下是使用通配符“%”查变量:
mysql> show variables like "%connect%";
+--------------------------+-------------------+
| Variable_name | Value |
+--------------------------+-------------------+
| character_set_connection | latin1 |
| collation_connection | latin1_swedish_ci |
| connect_timeout | 10 |
| init_connect | |
| max_connect_errors | 10 |
| max_connections | 151 |
| max_user_connections | 0 |
+--------------------------+-------------------+
7 rows in set (0.00 sec)
mysql> show variables like "%timeout%";
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| connect_timeout | 10 |
| delayed_insert_timeout | 300 |
| innodb_lock_wait_timeout | 50 |
| innodb_rollback_on_timeout | OFF |
| interactive_timeout | 28800 |
| net_read_timeout | 30 |
| net_write_timeout | 60 |
| slave_net_timeout | 3600 |
| table_lock_wait_timeout | 50 |
| wait_timeout | 28800 |
+----------------------------+-------+
10 rows in set (0.00 sec)
mysql> show variables like "%buffer%";
+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| bulk_insert_buffer_size | 8388608 |
| innodb_buffer_pool_size | 8388608 |
| innodb_log_buffer_size | 1048576 |
| join_buffer_size | 131072 |
| key_buffer_size | 8384512 |
| myisam_sort_buffer_size | 8388608 |
| net_buffer_length | 16384 |
| preload_buffer_size | 32768 |
| read_buffer_size | 131072 |
| read_rnd_buffer_size | 262144 |
| sort_buffer_size | 2097144 |
| sql_buffer_result | OFF |
+-------------------------+---------+
12 rows in set (0.00 sec)
mysql> show variables like "%err%";
//使用通配符查mysql错误日志存放位置,
//跟配置文件my.cnf里面的“[mysqld_safe]log-error=/var/log/mysqld.log”吻合
+--------------------+---------------------+
| Variable_name | Value |
+--------------------+---------------------+
| error_count | 0 |
| log_error | /var/log/mysqld.log |
| max_connect_errors | 10 |
| max_error_count | 64 |
| slave_skip_errors | OFF |
+--------------------+---------------------+
5 rows in set (0.00 sec)
mysql> exit
Bye
# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
mysql> repair table databasename.tablename;//修复表
mysql> repair table discuz.pre_forum_post;
+-----------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-----------------------+--------+----------+----------+
| discuz.pre_forum_post | repair | status | OK |
+-----------------------+--------+----------+----------+
1 row in set (0.00 sec)