日期:2014-05-16  浏览次数:20892 次

mysql-5.1.61-linux-x86_64-glibc23.tar.gz 安装笔记
1、建立mysql用户组,mysql用户,并且把mysql用户加入到mysql用户组中。  
建立mysql用户组:groupadd mysql  
建立mysql用户并加入mysql用户组:useradd mysql -g mysql -p mysql123456 -s /sbin/nologin -M  
说明:-g 是加入到mysql用户组,-p是设置密码,-s是设置shell,这里设置的是不让其登录,-M就是不建立用户目录。
 
2、把按照文件拷贝到:/usr/local/mysql,  
用的命令是cp –rf mysql-5.1.61-linux-x86_64-glibc23.tar.gz /usr/local/mysql ,  
然后到目录/usr/local/mysql下面解压缩文件:tar -zxvf mysql-5.1.61-linux-x86_64-glibc23.tar.gz


3、到mysql目录下,初始化mysql表,安装 mysql 默认数据库:
cd /usr/local/mysql  
[root@localhost mysql]# scripts/mysql_install_db --user=mysql  

控制台打印出:
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
..........

即说明安装成功。

4、修改目录权限,如下:
[root@localhost local]# chgrp -R mysql mysql  
[root@localhost local]# chown -R mysql mysql/data  

5、添加到系统自启动,如下:  
[root@localhost local]# cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld  
-- 添加到系统自启动
[root@localhost local]# chkconfig --add mysqld   
 
6、启动mysql服务进程,如下:  
[root@localhost local]# /etc/init.d/mysqld start  
7、查看mysql是否启动命令
a:启动完成查看mysql状态,命令: /etc/rc.d/init.d/mysqld status,看看m y s q l 是否已经启动.
[root@localhost local]# /etc/rc.d/init.d/mysqld status
SUCCESS! MySQL running (32508)
b: ps -aux | grep mysqld
c:netstat -tl | grep mysql
8、初次登陆mysql 并修改root 密码及设置可连接 主机
-- 默认密码为空
[root@localhost local]#/usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.61 MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;

---修改root 默认密码
update user set password=PASSWORD("adMin") where host='localhost' and user='root'
delete from user where password ='';
--设置可连接 主机; % 所有都可连接
update user set host='%' where host='localhost' and user='root'

9、退出重启mysql
[root@localhost local]#/etc/init.d/mysqld stop
[root@localhost local]#/etc/init.d/mysqld start

10、其他配置待续。。。。。。。