mysql 安装for linux_mysql安装for linux 之 (RPM包与TAR包方法)

[root@sam init.d]# chkconfig --list|grep mysql

mysql           0:off   1:off   2:off   3:off   4:off   5:off   6:off

[root@sam init.d]# chkconfig --level 2345 mysql on

[root@sam init.d]#chkconfig --list|grep mysql

mysql           0:off   1:off   2:on    3:on    4:on    5:on   6:off

6. 创建root管理员

[root@sam init.d]# mysqladmin -u root password 123456

Warning: Using a password on the command line interface can be insecure.

[root@sam init.d]# mysql

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@sam init.d]# mysql -u root -p

Enter password: 此处输入密码(123456)

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 10

Server version: 5.6.24-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2015, 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>

二、tar包安装方法:

0. 清理已安装的mysql程序包

同上,不在介绍

1. 建立用户组及用户

[root@suzzy~]# groupadd mysql

[root@suzzy ~]#useradd -g mysql mysql

2. 将下载好的mysql程序tar包上传至服务器

此处略过

3. 解压缩mysql程序包

[root@suzzy ~]#tar -zxvf mysql-advanced-5.6.22-linux-glibc2.5-x86_64.tar.gz

4. 将解压后的文件夹移动到/usr/local下并改名为mysql

[root@suzzy ~]# mv mysql-advanced-5.6.22-linux-glibc2.5-x86_64 /usr/local/mysql

5. 建立mysql组,建立mysql用户并且加入到mysql组中

[root@suzzy mysql]# groupadd mysql

[root@suzzy mysql]# useradd mysql -g mysql

6. 覆盖/etc/my.cnf (还是建议把源my.cnf 先改名字,DBA的直觉,不要轻意删除或覆盖)

[root@suzzy mysql]# pwd

/usr/local/mysql

[root@suzzy mysql]# cp my.cnf /etc

7.初试化表并且规定用mysql用户来访问

[root@suzzy mysql]# pwd

/usr/local/mysql

[root@suzzy mysql]# ./scripts/mysql_install_db --user=mysql

Installing MySQL system tables...2015-04-28 16:58:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-04-28 16:58:38 14302 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-04-28 16:58:38 14302 [Note] InnoDB: The InnoDB memory heap is disabled

2015-04-28 16:58:38 14302 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-04-28 16:58:38 14302 [Note] InnoDB: Memory barrier is not used

2015-04-28 16:58:38 14302 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-04-28 16:58:38 14302 [Note] InnoDB: Using Linux native AIO

2015-04-28 16:58:38 14302 [Note] InnoDB: Using CPU crc32 instructions

2015-04-28 16:58:38 14302 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-04-28 16:58:38 14302 [Note] InnoDB: Completed initialization of buffer pool

2015-04-28 16:58:38 14302 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2015-04-28 16:58:38 14302 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2015-04-28 16:58:38 14302 [Note] InnoDB: Database physically writes the file full: wait...

2015-04-28 16:58:38 14302 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2015-04-28 16:58:39 14302 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2015-04-28 16:58:39 14302 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2015-04-28 16:58:39 14302 [Warning] InnoDB: New log files created, LSN=45781

2015-04-28 16:58:39 14302 [Note] InnoDB: Doublewrite buffer not found: creating new

2015-04-28 16:58:39 14302 [Note] InnoDB: Doublewrite buffer created

2015-04-28 16:58:39 14302 [Note] InnoDB: 128 rollback segment(s) are active.

2015-04-28 16:58:39 14302 [Warning] InnoDB: Creating foreign key constraint system tables.

2015-04-28 16:58:39 14302 [Note] InnoDB: Foreign key constraint system tables created

2015-04-28 16:58:39 14302 [Note] InnoDB: Creating tablespace and datafile system tables.

2015-04-28 16:58:39 14302 [Note] InnoDB: Tablespace and datafile system tables created.

2015-04-28 16:58:39 14302 [Note] InnoDB: Waiting for purge to start

2015-04-28 16:58:39 14302 [Note] InnoDB: 5.6.22 started; log sequence number 0

2015-04-28 16:58:39 14302 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.

2015-04-28 16:58:39 14302 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.

2015-04-28 16:58:39 14302 [Note] Binlog end

2015-04-28 16:58:39 14302 [Note] InnoDB: FTS optimize thread exiting.

2015-04-28 16:58:39 14302 [Note] InnoDB: Starting shutdown...

2015-04-28 16:58:41 14302 [Note] InnoDB: Shutdown completed; log sequence number 1625977

OK

Filling help tables...2015-04-28 16:58:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-04-28 16:58:41 14324 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-04-28 16:58:41 14324 [Note] InnoDB: The InnoDB memory heap is disabled

2015-04-28 16:58:41 14324 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-04-28 16:58:41 14324 [Note] InnoDB: Memory barrier is not used

2015-04-28 16:58:41 14324 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-04-28 16:58:41 14324 [Note] InnoDB: Using Linux native AIO

2015-04-28 16:58:41 14324 [Note] InnoDB: Using CPU crc32 instructions

2015-04-28 16:58:41 14324 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-04-28 16:58:41 14324 [Note] InnoDB: Completed initialization of buffer pool

2015-04-28 16:58:41 14324 [Note] InnoDB: Highest supported file format is Barracuda.

2015-04-28 16:58:41 14324 [Note] InnoDB: 128 rollback segment(s) are active.

2015-04-28 16:58:41 14324 [Note] InnoDB: Waiting for purge to start

2015-04-28 16:58:41 14324 [Note] InnoDB: 5.6.22 started; log sequence number 1625977

2015-04-28 16:58:41 14324 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.

2015-04-28 16:58:41 14324 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.

2015-04-28 16:58:41 14324 [Note] Binlog end

2015-04-28 16:58:41 14324 [Note] InnoDB: FTS optimize thread exiting.

2015-04-28 16:58:41 14324 [Note] InnoDB: Starting shutdown...

2015-04-28 16:58:43 14324 [Note] InnoDB: Shutdown completed; log sequence number 1625987

OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'

./bin/mysqladmin -u root -h suzzy password 'new-password'

Alternatively you can run:

./bin/mysql_secure_installation

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file ./my.cnf on the system.

Because this file might be in use, it was not replaced,

but was used in bootstrap (unless you used --defaults-file)

and when you later start the server.

The new default config file was created as ./my-new.cnf,

please compare it with your file and take the changes you need.

8. 设定用户访问权限与启动,登录测试

[root@suzzy mysql]# chown -R root .

[root@suzzy mysql]#chown -R mysql data

[root@suzzy mysql]# bin/mysqld_safe --user=mysql &

[1] 19243

[root@suzzy mysql]# 150505 11:06:51 mysqld_safe Logging to '/usr/local/mysql/data/suzzy.err'.

150505 11:06:51 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

[root@suzzy mysql]#

[root@suzzy mysql]# ps -ef|grep mysql

root      19243  18204  0 11:06 pts/1    00:00:00 /bin/sh bin/mysqld_safe --user=mysql

mysql     19343  19243  5 11:06 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/suzzy.err --pid-file=/usr/local/mysql/data/suzzy.pid

root      19367  18204  0 11:06 pts/1    00:00:00 grep mysql

[root@suzzy mysql]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.22-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, 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>

9. 将support-files目录下mysql.server复制到 /etc/init.d下,进行启动停止服务测试

[root@suzzy mysql]#cp support-files/mysql.server /etc/init.d

[root@suzzy mysql]# /etc/init.d/mysql.server stop

Shutting down MySQL..[  OK  ]

[root@suzzy mysql]# /etc/init.d/mysql.server start

Starting MySQL.[  OK  ]

10. 设置环境变量中的PATH,这样就可以直接使用mysql相关命令

[root@suzzy mysql]# vi ~/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

安装报错:

[root@sam mysqlsetup]# rpm -ivh MySQL-server-advanced-5.6.24-1.el6.x86_64.rpm

Preparing...                ########################################### [100%]

file /usr/bin/my_print_defaults from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/my_print_defaults.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-5.1.66-2.el6_3.x86_64

file /usr/bin/innochecksum from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/myisam_ftdump from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/myisamchk from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/myisamlog from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/myisampack from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_convert_table_format from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_fix_extensions from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_install_db from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_secure_installation from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_tzinfo_to_sql from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_upgrade from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysql_zap from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysqlbug from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysqld_multi from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysqld_safe from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysqldumpslow from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysqlhotcopy from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/mysqltest from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/perror from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/replace from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/resolve_stack_dump from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/bin/resolveip from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/innochecksum.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/myisam_ftdump.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/myisamchk.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/myisamlog.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/myisampack.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql.server.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_convert_table_format.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_fix_extensions.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_install_db.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_secure_installation.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_tzinfo_to_sql.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_upgrade.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysql_zap.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysqlbug.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysqld_multi.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysqld_safe.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysqldumpslow.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysqlhotcopy.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/mysqltest.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/perror.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/replace.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/resolve_stack_dump.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man1/resolveip.1.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/man/man8/mysqld.8.gz from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/mysql/fill_help_tables.sql from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/mysql/mysql_system_tables.sql from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/mysql/mysql_system_tables_data.sql from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

file /usr/share/mysql/mysql_test_data_timezone.sql from install of MySQL-server-advanced-5.6.24-1.el6.x86_64 conflicts with file from package mysql-server-5.1.66-2.el6_3.x86_64

[root@sam mysqlsetup]#

总结:此次对mysql安装使用了RPM包与TAR包的两种方法,这两种方法相对初学者还是比较容易。因为我也是个初学者,所以有些地方的细节也未给出详细说明,只是安装使用而已。后续的学习过程中再不断完善。当然目前主流安装方法还有yum与make的安装,在以后的文章继续分享。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值