❶ 如何在linux中安装mysql
你好,你可以到mysql官网下载mysql编译好的二进制安装软件,然后选择经典安装。
1、解压32位安装包:进入安装包所在目录。
2、复制解压后的mysql目录到系统的本地软件。
3、添加系统mysql组和mysql用户:执行命令。
❷ mysql怎么在linux安装
安装环境:系统是 centos6.5
1、下载
下载地址:
下载版本:我这里选择的5.6.33,通用版,linux下64位
也可以直接复制64位的下载地址,通过命令下载:wget
2、解压
1
2
3
4
#解压
tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
#复制解压后的mysql目录
cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
3、添加用户组和用户
1
2
3
4
#添加用户组
groupadd mysql
#添加用户mysql 到用户组mysql
useradd -g mysql mysql
4、安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
cd /usr/local/mysql/<br>mkdir ./data/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
#修改启动脚本
vi /etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
#启动服务
service mysqld start
#测试连接
./mysql/bin/mysql -uroot
#加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql//bin<br>source /etc/profile
#启动mysql
service mysqld start
#关闭mysql
service mysqld stop
#查看运行状态
service mysqld status
5、错误
5.1 sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
解决1:更改 ‘mysql’数据库‘user’表‘host’项,从‘localhost’改成‘%’。
use mysql;
select 'host' from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
解决2:直接授权
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
5.2 安装时的一些错误
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: lio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install lio-devel
6、其他
6.1 配置环境变量
vi + /etc/profile
export PATH=....:/usr/local/mysql/bin
❸ linux中怎么安装mysql
1. 运行平台:CentOS 6.3 x86_64,基本等同于RHEL 6.3
2. 安装方法:
安装MySQL主要有两种方法:一种是通过源码自行编译安装,这种适合高级用户定制MySQL的特性,这里不做说明;另一种是通过编译过的二进制文件进行安装。二进制文件安装的方法又分为两种:一种是不针对特定平台的通用安装方法,使用的二进制文件是后缀为.tar.gz的压缩文件;第二种是使用RPM或其他包进行安装,这种安装进程会自动完成系统的相关配置,所以比较方便。
3. 下载安装包:
a. 官方下载地址:
http://dev.mysql.com/downloads/mysql/#downloads
或镜像文件下载:
http://dev.mysql.com/downloads/mirrors.html
2. 下载文件(根据操作系统选择相应的发布版本):
a. 通用安装方法
mysql-5.5.29-linux2.6-x86_64.tar.gz
b. RPM安装方法:
MySQL-server-5.5.29-2.el6.x86_64.rpm
MySQL-client-5.5.29-2.el6.x86_64.rpm
4. 通用安装步骤
a. 检查是否已安装,grep的-i选项表示匹配时忽略大小写
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
*可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸:载时使用了--nodeps选项,忽略了依赖关系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
b. 添加mysql组和mysql用户,用于设置mysql安装目录文件所有者和所属组。
[root@localhost JavaEE]#groupadd mysql
[root@localhost JavaEE]#useradd -r -g mysql mysql
*useradd -r参数表示mysql用户是系统用户,不可用于登录系统。
c. 将二进制文件解压到指定的安装目录,我们这里指定为/usr/local
[root@localhost ~]# cd/usr/local/
[root@localhost local]#tar zxvf /path/to/mysql-5.5.29-linux2.6-x86_64.tar.gz
*加压后在/usr/local/生成了解压后的文件夹mysql-5.5.29-linux2.6-x86_64,这名字太长,我们为它建立一个符号链接mysql,方便输入。
[root@localhost local]#ln -s mysql-5.5.29-linux2.6-x86_64 mysql
d. /usr/local/mysql/下的目录结构
Directory
Contents of Directory
bin
Client programs and the mysqld server
data
Log files, databases
docs
Manual in Info format
man
Unix manual pages
include
Include (header) files
lib
Libraries
scripts
mysql_install_db
share
Miscellaneous support files, including error messages, sample configuration files, SQL for database installation
sql-bench
Benchmarks
e. 进入mysql文件夹,也就是mysql所在的目录,并更改所属的组和用户。
[root@localhost local]#cd mysql
[root@localhost mysql]#chown -R mysql .
[root@localhost mysql]#chgrp -R mysql .
f. 执行mysql_install_db脚本,对mysql中的data目录进行初始化并创建一些系统表格。注意mysql服务进程mysqld运行时会访问data目录,所以必须由启动mysqld进程的用户(就是我们之前设置的mysql用户)执行这个脚本,或者用root执行,但是加上参数--user=mysql。
[root@localhost mysql]scripts/mysql_install_db --user=mysql
*如果mysql的安装目录(解压目录)不是/usr/local/mysql,那么还必须指定目录参数,如
[root@localhost mysql]scripts/mysql_install_db --user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data
*将mysql/目录下除了data/目录的所有文件,改回root用户所有,mysql用户只需作为mysql/data/目录下所有文件的所有者。
[root@localhost mysql]chown -R root .
[root@localhost mysql]chown -R mysql data
g. 复制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
h. 将mysqld服务加入开机自启动项。
*首先需要将scripts/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通过chkconfig命令将mysqld服务加入到自启动服务项中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服务名称mysqld就是我们将mysql.server复制到/etc/init.d/时重命名的名称。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
i. 重启系统,mysqld就会自动启动了。
*检查是否启动
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新启动,那可以直接手动启动。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
j. 运行客户端程序mysql,在mysql/bin目录中,测试能否连接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> quit
Bye
*此时会出现mysql>命令提示符,可以输入sql语句,输入quit或exit退出。为了避免每次都输入mysql的全路径/usr/local/mysql/bin/mysql,可将其加入环境变量中,在/etc/profile最后加入两行命令:
MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
这样就可以在shell中直接输入mysql命令来启动客户端程序了
[root@localhost mysql]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
5. RPM安装步骤
a. 检查是否已安装,grep的-i选项表示匹配时忽略大小写
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸载时使用了--nodeps选项,忽略了依赖关系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2. 安装MySQL的服务器端软件,注意切换到root用户:
[root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安装完成后,安装进程会在Linux中添加一个mysql组,以及属于mysql组的用户mysql。可通过id命令查看:
[root@localhost JavaEE]#id mysql
uid=496(mysql)gid=493(mysql) groups=493(mysql)
MySQL服务器安装之后虽然配置了相关文件,但并没有自动启动mysqld服务,需自行启动:
[root@localhost JavaEE]#service mysql start
Starting MySQL.. SUCCESS!
可通过检查端口是否开启来查看MySQL是否正常启动:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld
c. 安装MySQL的客户端软件:
[root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安装成功应该可以运行mysql命令,注意必须是mysqld服务以及开启:
[root@localhost JavaEE]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.5.29MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
d. RPM安装方式文件分布
Directory
Contents of Directory
/usr/bin
Client programs and scripts
/usr/sbin
The mysqld server
/var/lib/mysql
Log files, databases
/usr/share/info
Manual in Info format
/usr/share/man
Unix manual pages
/usr/include/mysql
Include (header) files
/usr/lib/mysql
Libraries
/usr/share/mysql
Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench
Benchmarks
❹ 在linux下怎么安装mysql数据库
1. 安装MySQL数据库
先从MySQL官网下载MySQL,然后进入所下载的安装文件所在目录,运行如下命令进行安装,其中MySQL-server-community-5.1.56-1.rhel5.i386.rpm为刚刚下载的MySQL数据库服务器的rpm包,然后使用/etc/rc.d/init.d/mysqlrestart命令重启MySQL服务:
[root@localhost ~]# rpm -ivh MySQL-server-community-5.1.56-1.rhel5.i386.rpm
[root@localhost ~]# /etc/rc.d/init.d/mysql restart
Shutting down MySQL..[确定]
Starting MySQL..[确定]
2. 配置MySQL数据库字符集
备注:配置MySQL数据库字符集的目的是方便的使用数据库,无需在每次连接的时候都要临时设置数据库字符集的,个人不建议采用这种方法,真正的工程项目都应该在连接数据库时临时设置数据库字符集,如此才便于系统的移植,而且又不会影响数据库服务器中的其他数据库的使用!
安装完成之后,需要配置MySQL的字符集配置,首先需要查找MySQL的配置文件的位置,由于MySQL的配置文件名是以.cnf结尾的,因此可用如下命令进行查找:
[root@localhost ~]# find / -iname '*.cnf' -print
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-small.cnf
/usr/share/doc/MySQL-server-community-5.1.56/my-large.cnf
/usr/share/doc/MySQL-server-community-5.1.56/my-medium.cnf
/usr/share/doc/MySQL-server-community-5.1.56/my-innodb-heavy-4G.cnf
/usr/share/doc/MySQL-server-community-5.1.56/my-huge.cnf
/usr/share/doc/MySQL-server-community-5.1.56/my-small.cnf
/etc/pki/tls/openssl.cnf
输入完命令“find / -iname '*.cnf'-print”回车后,屏幕便显示搜索到的MySQL配置文件,然后拷贝my-large.cnf、my-medium.cnf 、my-innodb-heavy-4G.cnf 、my-huge.cnf、my-small.cnf中任意的一个到/etc目录下,并命名为my.cnf,其命令如下所示:
[root@localhost ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@localhost ~]# vi /etc/my.cnf
然后,使用vi编辑器修改/etc/my.cnf文件,在[client]下添加: “default-character-set=gb2312”;在[mysqld]下添加:“default-character-set=gb2312”。如下所示:
# The following options will be passed to all MySQL clients
[client]
default-character-set=gb2312
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
default-character-set=gb2312
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
按一下Esc键,输入“:wq”后回车保存配置文件,输入“/etc/rc.d/init.d/mysqlrestart”重启MySQL服务,如下所示:
[root@localhost ~]# /etc/rc.d/init.d/mysql restart
Shutting down MySQL..[确定]
Starting MySQL..[确定]
最后,我们来验证MySQL服务器配置是否成功,首先登录MySQL,输入“mysql –uroot -p”回车,系统提示输入密码,登录成功后进入MySQL命令模式,如下所示:
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.56-community-log MySQL Community Server (GPL)
Copyright (c) 2000, 2010, 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>
在MySQL命令模式下分别输入“show variables like'collation_%';”、“show variables like 'character_set_%';”回车后显示字符集设置,如下所示:
mysql> show variables like 'collation_%';
+----------------------+-------------------+
| Variable_name | Value |
+----------------------+-------------------+
| collation_connection | gb2312_chinese_ci |
| collation_database | gb2312_chinese_ci |
| collation_server | gb2312_chinese_ci |
+----------------------+-------------------+
3 rows in set (0.05 sec)
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | gb2312 |
| character_set_connection | gb2312 |
| character_set_database | gb2312 |
| character_set_filesystem | binary |
| character_set_results | gb2312 |
| character_set_server | gb2312 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql>
根据以上查询结果可知我们设置的MySQL数据库配置信息已经生效,至此完成MySQL的服务器的安装与配置。
3.关于MySQL数据库的一些注意事项
3.1 远程连接mysql速度慢
解决方法:
在MySQL服务器的配置(/etc/my.cnf)中增加一个如下配置后速度飞快。
[mysqld]
skip-name-resolve
备注:这样就能禁用DNS解析,连接速度会快很多。不过,这样的话就不能在MySQL的授权表中使用主机名了而只能用ip格式。
3.2 重启数据库后,发现无需密码(或者任何密码)即可以连接
解决方法:
检查你的MySQL配置文件(/etc/my.cnf)中是不是多了一条语句:“skip-grant-tables”,删除(注释)该语句,重新配置MySQL密码,再次重启MySQL服务即可!
备注:若使用skip-grant-tables系统将对任何用户的访问不做任何访问控制,但可以用 mysqladmin flush-privileges或mysqladmin reload来开启访问控制;默认情况是show databases语句对所有用户开放,如果mysql服务器没有开远程帐户,就在/etc/my.cnf里面加上skip-grant-tables。
❺ 怎么在linux上安装mysql
1. 运行平台:CentOS 6.3 x86_64,基本等同于RHEL 6.3
2. 安装方法:
安装MySQL主要有两种方法:一种是通过源码自行编译安装,这种适合高级用户定制MySQL的特性,这里不做说明;另一种是通过编译过的二进制文件进行安装。二进制文件安装的方法又分为两种:一种是不针对特定平台的通用安装方法,使用的二进制文件是后缀为.tar.gz的压缩文件;第二种是使用RPM或其他包进行安装,这种安装进程会自动完成系统的相关配置,所以比较方便。
3. 下载安装包:
a. 官方下载地址:
http://dev.mysql.com/downloads/mysql/#downloads
或镜像文件下载:
http://dev.mysql.com/downloads/mirrors.html
2. 下载文件(根据操作系统选择相应的发布版本):
a. 通用安装方法
mysql-5.5.29-linux2.6-x86_64.tar.gz
b. RPM安装方法:
MySQL-server-5.5.29-2.el6.x86_64.rpm
MySQL-client-5.5.29-2.el6.x86_64.rpm
4. 通用安装步骤
a. 检查是否已安装,grep的-i选项表示匹配时忽略大小写
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
*可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸:载时使用了--nodeps选项,忽略了依赖关系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
b. 添加mysql组和mysql用户,用于设置mysql安装目录文件所有者和所属组。
[root@localhost JavaEE]#groupadd mysql
[root@localhost JavaEE]#useradd -r -g mysql mysql
*useradd -r参数表示mysql用户是系统用户,不可用于登录系统。
c. 将二进制文件解压到指定的安装目录,我们这里指定为/usr/local
[root@localhost ~]# cd/usr/local/
[root@localhost local]#tar zxvf /path/to/mysql-5.5.29-linux2.6-x86_64.tar.gz
*加压后在/usr/local/生成了解压后的文件夹mysql-5.5.29-linux2.6-x86_64,这名字太长,我们为它建立一个符号链接mysql,方便输入。
[root@localhost local]#ln -s mysql-5.5.29-linux2.6-x86_64 mysql
d. /usr/local/mysql/下的目录结构
Directory
Contents of Directory
bin
Client programs and the mysqld server
data
Log files, databases
docs
Manual in Info format
man
Unix manual pages
include
Include (header) files
lib
Libraries
scripts
mysql_install_db
share
Miscellaneous support files, including error messages, sample configuration files, SQL for database installation
sql-bench
Benchmarks
e. 进入mysql文件夹,也就是mysql所在的目录,并更改所属的组和用户。
[root@localhost local]#cd mysql
[root@localhost mysql]#chown -R mysql .
[root@localhost mysql]#chgrp -R mysql .
f. 执行mysql_install_db脚本,对mysql中的data目录进行初始化并创建一些系统表格。注意mysql服务进程mysqld运行时会访问data目录,所以必须由启动mysqld进程的用户(就是我们之前设置的mysql用户)执行这个脚本,或者用root执行,但是加上参数--user=mysql。
[root@localhost mysql]scripts/mysql_install_db --user=mysql
*如果mysql的安装目录(解压目录)不是/usr/local/mysql,那么还必须指定目录参数,如
[root@localhost mysql]scripts/mysql_install_db --user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data
*将mysql/目录下除了data/目录的所有文件,改回root用户所有,mysql用户只需作为mysql/data/目录下所有文件的所有者。
[root@localhost mysql]chown -R root .
[root@localhost mysql]chown -R mysql data
g. 复制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
h. 将mysqld服务加入开机自启动项。
*首先需要将scripts/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通过chkconfig命令将mysqld服务加入到自启动服务项中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服务名称mysqld就是我们将mysql.server复制到/etc/init.d/时重命名的名称。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
i. 重启系统,mysqld就会自动启动了。
*检查是否启动
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新启动,那可以直接手动启动。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
j. 运行客户端程序mysql,在mysql/bin目录中,测试能否连接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> quit
Bye
*此时会出现mysql>命令提示符,可以输入sql语句,输入quit或exit退出。为了避免每次都输入mysql的全路径/usr/local/mysql/bin/mysql,可将其加入环境变量中,在/etc/profile最后加入两行命令:
MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
这样就可以在shell中直接输入mysql命令来启动客户端程序了
[root@localhost mysql]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
5. RPM安装步骤
a. 检查是否已安装,grep的-i选项表示匹配时忽略大小写
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
可见已经安装了库文件,应该先卸载,不然会出现覆盖错误。注意卸载时使用了--nodeps选项,忽略了依赖关系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2. 安装MySQL的服务器端软件,注意切换到root用户:
[root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安装完成后,安装进程会在Linux中添加一个mysql组,以及属于mysql组的用户mysql。可通过id命令查看:
[root@localhost JavaEE]#id mysql
uid=496(mysql)gid=493(mysql) groups=493(mysql)
MySQL服务器安装之后虽然配置了相关文件,但并没有自动启动mysqld服务,需自行启动:
[root@localhost JavaEE]#service mysql start
Starting MySQL.. SUCCESS!
可通过检查端口是否开启来查看MySQL是否正常启动:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld
c. 安装MySQL的客户端软件:
[root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安装成功应该可以运行mysql命令,注意必须是mysqld服务以及开启:
[root@localhost JavaEE]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.5.29MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
d. RPM安装方式文件分布
Directory
Contents of Directory
/usr/bin
Client programs and scripts
/usr/sbin
The mysqld server
/var/lib/mysql
Log files, databases
/usr/share/info
Manual in Info format
/usr/share/man
Unix manual pages
/usr/include/mysql
Include (header) files
/usr/lib/mysql
Libraries
/usr/share/mysql
Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench
Benchmarks
❻ linux怎么安装mysql5.5
你好,Linux下安装MySQL方法如下,供参考,具体安装方式以你是用Linux版本不同有微笑的差异,但大致安装方法和思路不会变,
❼ linux怎么安装mysql
一般有下面几种方法:(以红帽系Linux为例)
1、yum install mysql mysql-server
这种版本通常比较旧
2、rpm包离线安装
需要先去MySQL官网下载rpm包
3、源码编译安装
需要先去MySQL官网下载源码
详细安装方法建议网络搜一下MySQL安装教程。