1 下载MySQL数据库l到/usr/local/src/
[root@xin tmp]# cd /usr/local/src/
[root@xin src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# ls
mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xuexi src]# du -sh mysql-5.1.73-linux-i686-glibc23.tar.gz
124M mysql-5.1.73-linux-i686-glibc23.tar.gz
2 解压
[root@xin src]# tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# ls
mysql-5.1.73-linux-i686-glibc23
mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# du -sh mysql-5.1.73-linux-i686-glibc23
410M mysql-5.1.73-linux-i686-glibc23
3 把解压完的数据移动到/usr/local/mysql
[root@xin src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
4 建立mysql用户
[root@xin src]# useradd -s /sbin/nologin -M mysql
5 初始化数据库
[root@xin src]# cd /usr/local/mysql/
[root@xin mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xin mysql]# mkdir -p /data/mysql(独立一个/data/分区)
[root@xin mysql]# chown -R mysql /data/mysql/
[root@xin mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
--user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。
[root@xuexi mysql]# echo $? (结果为0,说明运行结果正常)
0
6 拷贝配置文件
[root@xuexi mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xuexi mysql]# cd support-files/
[root@xuexi support-files]# ls
binary-configure my-huge.cnf mysqld_multi.server
config.huge.ini my-innodb-heavy-4G.cnf mysql-log-rotate
config.medium.ini my-large.cnf mysql.server
config.small.ini my-medium.cnf ndb-config-2-node.ini
magic my-small.cnf
[root@xuexi support-files]# cp my-large.cnf /etc/my.cnf 如果新版本没有my-large.cnf 进入配置文件
vim /etc/my.cnf 添加安装路径 basedir = /usr/local/mysql/mysql-5.6.29-linux-glibc2.5-x86_64/ 这样就可以启动服务了!
7 拷贝启动脚本文件并修改其属性
[root@xuexi support-files]# ls
binary-configure my-huge.cnf mysqld_multi.server
config.huge.ini my-innodb-heavy-4G.cnf mysql-log-rotate
config.medium.ini my-large.cnf mysql.server
config.small.ini my-medium.cnf ndb-config-2-node.ini
magic my-small.cnf
[root@xuexi support-files]# ls /etc/init.d/
abrt-ccpp cgred kdump nfslock restorecond smartd
abrtd cpuspeed killall ntpd rngd sshd
abrt-oops crond lvm2-lvmetad ntpdate rpcbind sssd
acpid cups lvm2-monitor numad rpcgssd sysstat
atd functions mdmonitor oddjobd rpcidmapd udev-post
auditd haldaemon messagebus portreserve rpcsvcgssd winbind
autofs halt netconsole postfix rsyslog ypbind
blk-availability ip6tables netfs psacct sandbox
certmonger iptables network quota_nld saslauthd
cgconfig irqbalance nfs rdisc single
[root@xuexi support-files]# cp mysql.server /etc/init.d/mysqld
[root@xuexi support-files]# vi /etc/init.d/mysqld
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql
datadir=/data/mysql/
[root@xuexi support-files]#ll /etc/init.d/mysqld (查看权限)
-rwxr-xr-x. 1 root root 12511 4月 8 17:00 /etc/init.d/mysqld
9 把启动脚本加入系统服务项,并设定开机启动,启动mysql
[root@xuexi support-files]# chkconfig --add mysqld
[root@xuexi support-files]# chkconfig mysqld on
[root@xuexi support-files]# chkconfig --list |grep mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@xuexi support-files]# /etc/init.d/mysqld start
Starting MySQL.... [确定]
10 检查mysql是否启动
[root@xuexi support-files]# ps aux |grep mysql
root 1922 0.0 0.1 6684 1264 pts/0 S 17:06 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/ --pid-file=/data/mysql//xuexi.pid
mysql 2046 2.9 4.3 390536 44656 pts/0 Sl 17:06 0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql --log-error=/data/mysql//xuexi.err --pid-file=/data/mysql//xuexi.pid --socket=/tmp/mysql.sock --port=3306
root 2072 0.0 0.0 6052 764 pts/0 S+ 17:07 0:00 grep mysql
[root@xuexi support-files]# netstat -lnp|grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2046/mysqld
unix 2 [ ACC ] STREAM LISTENING 20155 2046/mysqld /tmp/mysql.sock
到此mysql安装成功了!
11.给mysql增超级权限并允许远程访问
(用户名)(本机ip地址) (用户名密码)
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.3‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
本文出自 “11551192” 博客,请务必保留此出处http://11561192.blog.51cto.com/11551192/1775304
原文地址:http://11561192.blog.51cto.com/11551192/1775304