现在的位置: 首页 > 综合 > 正文

linux mysql的安装及一些配置方法

2013年08月23日 ⁄ 综合 ⁄ 共 1574字 ⁄ 字号 评论关闭

1.检查以前安装的MySQL,卸载。
rpm -qa|grep -i mysql
rpm -e XXXXX
注如果出现两条相同的,则使用rpm -e --allmatches

2.安装rpm包。
rpm -ivh MySQL-server-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-shared-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-community-5.1.37-0.rhel5.x86_64.rpm
rpm -ivh MySQL-client-community-5.1.37-0.rhel5.x86_64.rpm

3.cp 参数文件到 /etc/my.cnf
find / -name "my*.cnf"
添加参数
transaction-isolation=READ-COMMITTED
default-storage-engine=INNODB
innodb_flush_log_at_trx_commit=2

4.更新权限及用户
mysql -u root -p

use mysql;
select user,host from user;
delete from user where user <> 'root';
delete from user where host <> 'localhost';
update user set host ='%' where user ='root';
select user,host from user;

更新user表到如下状态
mysql> select user,host from user;
+------+------+
| user | host |
+------+------+
| root | %    |
+------+------+
1 row in set (0.00 sec)

创建用户
grant select,insert,update,delete,create,drop,alter,index,RELOAD, lock tables, execute, create routine, alter routine,Create temporary tables 
on *.* to mysql@"%" identified by "123456";

set global transaction isolation level read committed;

set session transaction isolation level read committed;

更新权限
flush privileges;

5.设置密码(123456)
mysqladmin -u root -p password ×××
####mysqladmin -u root -p password mypasswd

6.重启服务,验证设置。
/etc/init.d/mysql restart
登陆mysql

卸载驱动
rpm -e --justdb mysql-connector-odbc-5.1.5-0

key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 1234 K
bytes of memory

MySQL 忘记口令的解决办法
如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
启动 MySQL :bin/safe_mysqld --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是
use mysql;
update user set password=password("new_pass") where user="root";
update user set password=password("×××") where user="root";
flush privileges;

重新杀 MySQL ,用正常方法启动 MySQL 。

抱歉!评论已关闭.