linux下安装mysql
一下是linux查看mysql代码状态
[root@s1 dsz]# rpm -qa|grep mysql
mysql-server-5.5.29-1.fc16.i686
mysql-5.5.29-1.fc16.i686
mysql-libs-5.5.29-1.fc16.i686
mysql-devel-5.5.29-1.fc16.i686
[root@s1 dsz]# ps -ef|grep mysqld
root 1923 1855 0 14:57 pts/0 00:00:00 grep --color=auto mysqld
[root@s1 dsz]# ps -aux|grep mysql
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1931 0.0 0.0 6304 808 pts/0 S+ 14:58 0:00 grep --color=auto mysql
[root@s1 dsz]# rpm -ql mysql
/usr/bin/msql2mysql
/usr/bin/my_print_defaults
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_find_rows
/usr/bin/mysql_waitpid
/usr/bin/mysqlaccess
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlshow
/usr/bin/mysqlslap
/usr/lib/mysql/mysql_config
/usr/share/doc/mysql-5.5.29
/usr/share/doc/mysql-5.5.29/COPYING
/usr/share/doc/mysql-5.5.29/README
/usr/share/doc/mysql-5.5.29/README.mysql-docs
/usr/share/doc/mysql-5.5.29/README.mysql-license
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_config.1.gz
/usr/share/man/man1/mysql_find_rows.1.gz
/usr/share/man/man1/mysql_waitpid.1.gz
/usr/share/man/man1/mysqlaccess.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlshow.1.gz
/usr/share/man/man1/mysqlslap.1.gz
[root@s1 dsz]# /etc/init.d/mysql start
bash: /etc/init.d/mysql: 没有那个文件或目录
[root@s1 dsz]# mysqladmin start
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[root@s1 dsz]# rpm -qa mysql
mysql-5.5.29-1.fc16.i686
[root@s1 dsz]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
mysqld.service - MySQL database server
Loaded: loaded (/lib/systemd/system/mysqld.service; disabled)
Active: inactive (dead)
CGroup: name=systemd:/system/mysqld.service
[root@s1 dsz]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Job failed. See system logs and 'systemctl status' for details. 展开
2016-01-14 · 做真实的自己 用良心做教育
方法如下:
到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (glibc 2.5) (x86, 64-bit),32位系统下载Linux - Generic (glibc 2.5) (x86, 32-bit)
解压32位安装包:
进入安装包所在目录,执行命令:tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz
复制解压后的mysql目录到系统的本地软件目录:
执行命令:cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r
注意:目录结尾不要加/
添加系统mysql组和mysql用户:
执行命令:groupadd mysql和useradd -r -g mysql mysql
安装数据库:
进入安装mysql软件目录:执行命令 cd /usr/local/mysql
修改当前目录拥有者为mysql用户:执行命令 chown -R mysql:mysql ./
安装数据库:执行命令 ./scripts/mysql_install_db --user=mysql
修改当前目录拥有者为root用户:执行命令 chown -R root:root ./
修改当前data目录拥有者为mysql用户:执行命令 chown -R mysql:mysql data
到此数据库安装完毕
启动mysql服务和添加开机启动mysql服务:
添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysql,把启动脚本放到开机初始化目录
启动mysql服务:执行命令service mysql start
执行命令:ps -ef|grep mysql 看到mysql服务说明启动成功,如图
修改mysql的root用户密码,root初始密码为空的:
执行命令:./bin/mysqladmin -u root password '密码'
把mysql客户端放到默认路径:
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
2、去官网下载对应的server端和client端的rpm包安装
3、修改配置文件如果需要的话(/ect/my.cnf,如果该文件没有可以自己添加一个)
4、启动mysql
Linux系统上安装MySQL数据库