linux下安装MySQL及修改权限和用户

1.检查以前安装的MySQL,卸载。
rpm -qa|grep -i mysql
rpm -e XXXXX

注:如果出现两条相同的,则使用rpm -e --allmatches

2.cp参数文件到/etc/my.cnf(注意调整my.cnf内存大小)

3.安装rpm包。
rpm -ivh MySQL-server-5.5.8-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-5.5.8-1.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-5.5.8-1.rhel5.x86_64.rpm
rpm -ivh MySQL-shared-5.5.8-1.rhel5.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.5.8-1.rhel5.x86_64.rpm

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, lock tables, execute, create routine, alter routine,Create temporary tables  

on *.* to mysql@"%" identified by "123456";


更新权限
flush privileges;


5.设置密码(123456)
mysqladmin -u root -p password ufsoft

####mysqladmin -u root -p password mypasswd


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

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

数据库启动命令:
ps aux|grep mysql

解压包:tar zxvf  ****.tar.gz
导入数据:mysql –uroot –p123456 ename_222.sql
导出数据: mysql dump
改数据库配置:
set global  tmp_table_size=2009715200
set global max_heap_table_size=2009715200

你可能感兴趣的:(mysql)