阅读更多
CentOS 6.3 x64 安装 mysql-5.5.27.tar.gz
1.安装所需相关库文件:
# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
2.安装cmake和make
# yum install -y cmake
# yum install -y make
3.安装过程
(1)创建目录、用户和权限
# mkdir -p /usr/local/mysql #建立mysql安装目录
# mkdir -p /usr/local/mysql/data #建立mysql数据库目录
# groupadd mysql #添加mysql组
# useradd -g mysql mysql #添加一个mysql用户并加入到mysql组中
# chown -R mysql.mysql /usr/local/mysql/data/ #将/data/mysql目录的所有权赋予mysql组中的mysql用户
(2)安装mysql
下载地址:http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.27.tar.gz
tar -zxvf mysql-5.5.27.tar.gz
# cd mysql-5.5.27
cmake -DCMAKE_INSTALL_PREFIX=/backup/mysql-5.5.27-install -DMYSQL_UNIX_ADDR=/backup/mysql-5.5.27-install/data/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/backup/mysql-5.5.27-install/data/ -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3307
make && make install
cp /backup/mysql-5.5.27-install/support-files/my-medium.cnf /etc/my.cnf
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/backup/mysql-5.5.27-install --datadir=/backup/mysql-5.5.27-install/data/ ##初始化数据库cp cp /backup/mysql-5.5.27-install/support-files/mysql.server /etc/init.d/mysql #设置开机启动mysql
chmod 755 /etc/init.d/mysql
chkconfig mysql on #开机启动
echo 'export PATH=/backup/mysql-5.5.27-install/bin:$PATH' >> /etc/profile #将mysql的安装路径加入PATH
source /etc/profile #使配置立即生效
/etc/init.d/mysql start #启动mysql(如启动后不能登录,则重启系统)
netstat -nat | grep 3307
(3)防火墙开放3306端口
# vim /etc/sysconfig/iptables
添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3307 -j ACCEPT
重启防火墙服务
(4)设置和修改root用户密码
mysql修改,可在mysql命令行执行如下:
[root@localhost ~]# mysql -u root -p //首次登录可使用[root@localhost ~]# mysql
mysql> use mysql;
mysql> update user set password= password ("wepic123456");(用这句)
(5)开启允许远程连接
mysql> select `Host`,`User` from user;
mysql> update user set `Host` = '%' where `User` = 'root' limit 1;
mysql> quit
注意在mysql 命令行形式下一定要输入";"
重启一下mysql服务,
# /etc/init.d/mysql restart
- 大小: 186.5 KB