安裝mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
安裝mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
0、首先解壓
[root@VM_83_223_centos ~]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
1、建立mysql使用者
[root@VM_83_223_centos scripts]# useradd mysql
2、設定mysql使用者的密碼
[root@VM_83_223_centos scripts]# passwd mysql
Changing password for user mysql.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
3、設定/usr/local/mysql目錄的許可權
[root@VM_83_223_centos local]# mkdir mysql
[root@VM_83_223_centos local]#
[root@VM_83_223_centos local]# chown -R mysql:mysql mysql/
4、執行mysql安裝指令碼,報錯
[root@VM_83_223_centos scripts]# ./mysql_install_db
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper
解決方法:
安裝autoconf庫,此包安裝時會安裝Data::Dumper模組
[root@VM_83_223_centos scripts]# yum install autoconf
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
--> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(Data::Dumper) for package: autoconf-2.69-11.el7.noarch
--> Running transaction check
---> Package m4.x86_64 0:1.4.16-10.el7 will be installed
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================
Installing:
autoconf noarch 2.69-11.el7 os 701 k
Installing for dependencies:
m4 x86_64 1.4.16-10.el7 os 256 k
perl-Data-Dumper x86_64 2.145-3.el7 os 47 k
Transaction Summary
===================================================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 1.0 M
Installed size: 2.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): m4-1.4.16-10.el7.x86_64.rpm | 256 kB 00:00:00
(2/3): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(3/3): autoconf-2.69-11.el7.noarch.rpm | 701 kB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 5.7 MB/s | 1.0 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : m4-1.4.16-10.el7.x86_64 1/3
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 2/3
Installing : autoconf-2.69-11.el7.noarch 3/3
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 1/3
Verifying : m4-1.4.16-10.el7.x86_64 2/3
Verifying : autoconf-2.69-11.el7.noarch 3/3
Installed:
autoconf.noarch 0:2.69-11.el7
Dependency Installed:
m4.x86_64 0:1.4.16-10.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7
Complete!
5、安裝成功後,再次執行安裝指令碼,又出現報錯
root@VM_83_223_centos scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
root@VM_83_223_centos scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
按照報錯資訊,去mysql安裝目錄的bin目下查詢是否有my_print_defaults,發現有這個檔案
[root@VM_83_223_centos ~]# ls mysql-5.6.36-linux-glibc2.5-x86_64/bin/
innochecksum mysql mysql_client_test mysqld_multi mysqlhotcopy mysqltest replace
msql2mysql mysqlaccess mysql_client_test_embedded mysqld_safe mysqlimport mysqltest_embedded resolveip
myisamchk mysqlaccess.conf mysql_config mysqldump mysql_plugin mysql_tzinfo_to_sql resolve_stack_dump
myisam_ftdump mysqladmin mysql_config_editor mysqldumpslow mysql_secure_installation mysql_upgrade
myisamlog mysqlbinlog mysql_convert_table_format mysql_embedded mysql_setpermission mysql_waitpid
myisampack mysqlbug mysqld mysql_find_rows mysqlshow mysql_zap
my_print_defaults mysqlcheck mysqld-debug mysql_fix_extensions mysqlslap perror
看來其實不是沒有這個檔案,不是這個問題。認真檢視報錯資訊,可注意到那個路徑是相對路徑,是以mysql的安裝目錄為起始。而初始化則是進去初始化指令碼目錄裡執行指令碼,而在這個目錄下不會有./bin/my_print_defaults的。所以回到安裝目錄以相對路徑去執行初始化指令碼。
解決方法:
(1)首先將解壓後的所有檔案都複製到mysql的安裝目錄下/usr/bin/mysql
[root@VM_83_223_centos ~]# cp -R mysql-5.6.36-linux-glibc2.5-x86_64/* /usr/local/mysql/
[root@VM_83_223_centos ~]# cd /usr/local/
[root@VM_83_223_centos local]# cd mysql/
[root@VM_83_223_centos mysql]# ll
total 68
drwxr-xr-x 2 root root 4096 Mar 27 20:59 bin
-rw-r--r-- 1 root root 17987 Mar 27 20:59 COPYING
drwxr-xr-x 3 root root 4096 Mar 27 20:59 data
drwxr-xr-x 2 root root 4096 Mar 27 20:59 docs
drwxr-xr-x 3 root root 4096 Mar 27 20:59 include
drwxr-xr-x 3 root root 4096 Mar 27 20:59 lib
drwxr-xr-x 4 root root 4096 Mar 27 20:59 man
drwxr-xr-x 10 root root 4096 Mar 27 21:00 mysql-test
-rw-r--r-- 1 root root 2496 Mar 27 20:59 README
drwxr-xr-x 2 root root 4096 Mar 27 21:00 scripts
drwxr-xr-x 28 root root 4096 Mar 27 21:00 share
drwxr-xr-x 4 root root 4096 Mar 27 21:00 sql-bench
drwxr-xr-x 2 root root 4096 Mar 27 21:00 support-files
(2)採用絕對路徑執行安裝指令碼
[root@VM_83_223_centos mysql]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...2018-03-27 21:01:02 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-27 21:01:02 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-03-27 21:01:02 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.36) starting as process 20251 ...
2018-03-27 21:01:02 20251 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-03-27 21:01:02 20251 [Note] InnoDB: The InnoDB memory heap is disabled
2018-03-27 21:01:02 20251 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-27 21:01:02 20251 [Note] InnoDB: Memory barrier is not used
2018-03-27 21:01:02 20251 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-03-27 21:01:02 20251 [Note] InnoDB: Using Linux native AIO
2018-03-27 21:01:02 20251 [Note] InnoDB: Using CPU crc32 instructions
2018-03-27 21:01:02 20251 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-03-27 21:01:02 20251 [Note] InnoDB: Completed initialization of buffer pool
2018-03-27 21:01:02 20251 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-03-27 21:01:02 20251 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-03-27 21:01:02 20251 [Note] InnoDB: Database physically writes the file full: wait...
2018-03-27 21:01:02 20251 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-03-27 21:01:03 20251 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-03-27 21:01:03 20251 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-03-27 21:01:03 20251 [Warning] InnoDB: New log files created, LSN=45781
2018-03-27 21:01:03 20251 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-03-27 21:01:03 20251 [Note] InnoDB: Doublewrite buffer created
2018-03-27 21:01:03 20251 [Note] InnoDB: 128 rollback segment(s) are active.
2018-03-27 21:01:03 20251 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-27 21:01:03 20251 [Note] InnoDB: Foreign key constraint system tables created
2018-03-27 21:01:03 20251 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-03-27 21:01:03 20251 [Note] InnoDB: Tablespace and datafile system tables created.
2018-03-27 21:01:03 20251 [Note] InnoDB: Waiting for purge to start
2018-03-27 21:01:03 20251 [Note] InnoDB: 5.6.36 started; log sequence number 0
2018-03-27 21:01:05 20251 [Note] Binlog end
2018-03-27 21:01:05 20251 [Note] InnoDB: FTS optimize thread exiting.
2018-03-27 21:01:05 20251 [Note] InnoDB: Starting shutdown...
2018-03-27 21:01:06 20251 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2018-03-27 21:01:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-27 21:01:06 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-03-27 21:01:06 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.36) starting as process 20274 ...
2018-03-27 21:01:06 20274 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-03-27 21:01:06 20274 [Note] InnoDB: The InnoDB memory heap is disabled
2018-03-27 21:01:06 20274 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-27 21:01:06 20274 [Note] InnoDB: Memory barrier is not used
2018-03-27 21:01:06 20274 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-03-27 21:01:06 20274 [Note] InnoDB: Using Linux native AIO
2018-03-27 21:01:06 20274 [Note] InnoDB: Using CPU crc32 instructions
2018-03-27 21:01:06 20274 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-03-27 21:01:06 20274 [Note] InnoDB: Completed initialization of buffer pool
2018-03-27 21:01:06 20274 [Note] InnoDB: Highest supported file format is Barracuda.
2018-03-27 21:01:06 20274 [Note] InnoDB: 128 rollback segment(s) are active.
2018-03-27 21:01:06 20274 [Note] InnoDB: Waiting for purge to start
2018-03-27 21:01:06 20274 [Note] InnoDB: 5.6.36 started; log sequence number 1625977
2018-03-27 21:01:06 20274 [Note] Binlog end
2018-03-27 21:01:06 20274 [Note] InnoDB: FTS optimize thread exiting.
2018-03-27 21:01:06 20274 [Note] InnoDB: Starting shutdown...
2018-03-27 21:01:08 20274 [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:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h VM_83_223_centos password 'new-password'
Alternatively you can run:
/usr/local/mysql/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 . ; /usr/local/mysql/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
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
6、修改相關的配置檔案
[root@VM_83_223_centos mysql]# ll
total 72
drwxr-xr-x 2 root root 4096 Mar 27 20:59 bin
-rw-r--r-- 1 root root 17987 Mar 27 20:59 COPYING
drwxr-xr-x 5 mysql mysql 4096 Mar 27 21:01 data
drwxr-xr-x 2 root root 4096 Mar 27 20:59 docs
drwxr-xr-x 3 root root 4096 Mar 27 20:59 include
drwxr-xr-x 3 root root 4096 Mar 27 20:59 lib
drwxr-xr-x 4 root root 4096 Mar 27 20:59 man
-rw-r--r-- 1 root root 943 Mar 27 21:01 my.cnf
drwxr-xr-x 10 root root 4096 Mar 27 21:00 mysql-test
-rw-r--r-- 1 root root 2496 Mar 27 20:59 README
drwxr-xr-x 2 root root 4096 Mar 27 21:00 scripts
drwxr-xr-x 28 root root 4096 Mar 27 21:00 share
drwxr-xr-x 4 root root 4096 Mar 27 21:00 sql-bench
drwxr-xr-x 2 root root 4096 Mar 27 21:00 support-files
[root@VM_83_223_centos mysql]# cd support-files/
[root@VM_83_223_centos support-files]# ll
total 32
-rwxr-xr-x 1 root root 1153 Mar 27 21:00 binary-configure
-rw-r--r-- 1 root root 773 Mar 27 21:00 magic
-rw-r--r-- 1 root root 1126 Mar 27 21:00 my-default.cnf
-rwxr-xr-x 1 root root 1061 Mar 27 21:00 mysqld_multi.server
-rwxr-xr-x 1 root root 894 Mar 27 21:00 mysql-log-rotate
-rwxr-xr-x 1 root root 10565 Mar 27 21:00 mysql.server
[root@VM_83_223_centos support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@VM_83_223_centos support-files]# cp mysql.server /etc/init.d/mysql
[root@VM_83_223_centos mysql]# ll
total 72
drwxr-xr-x 2 root root 4096 Mar 27 20:59 bin
-rw-r--r-- 1 root root 17987 Mar 27 20:59 COPYING
drwxr-xr-x 5 mysql mysql 4096 Mar 27 21:01 data
drwxr-xr-x 2 root root 4096 Mar 27 20:59 docs
drwxr-xr-x 3 root root 4096 Mar 27 20:59 include
drwxr-xr-x 3 root root 4096 Mar 27 20:59 lib
drwxr-xr-x 4 root root 4096 Mar 27 20:59 man
-rw-r--r-- 1 root root 943 Mar 27 21:01 my.cnf
drwxr-xr-x 10 root root 4096 Mar 27 21:00 mysql-test
-rw-r--r-- 1 root root 2496 Mar 27 20:59 README
drwxr-xr-x 2 root root 4096 Mar 27 21:00 scripts
drwxr-xr-x 28 root root 4096 Mar 27 21:00 share
drwxr-xr-x 4 root root 4096 Mar 27 21:00 sql-bench
drwxr-xr-x 2 root root 4096 Mar 27 21:00 support-files
[root@VM_83_223_centos support-files]#vim /etc/init.d/mysql #若mysql的安裝目錄是/usr/local/mysql,則可省略此步
修改檔案中的兩個變更值
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
7、配置環境變數
[root@VM_83_223_centos support-files]#vim /etc/profile
新增下面兩行
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
使修改生效
[root@VM_83_223_centos support-files]#source /etc/profile
8、配置服務,啟動服務並設定為自啟動
[root@VM_83_223_centos support-files]# chkconfig --add mysql
[root@VM_83_223_centos support-files]#
[root@VM_83_223_centos support-files]# systemctl status mysql.service
● mysql.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysql; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
[root@VM_83_223_centos support-files]#
[root@VM_83_223_centos support-files]# systemctl start mysql.service
[root@VM_83_223_centos support-files]#
[root@VM_83_223_centos support-files]# systemctl status mysql.service
● mysql.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysql; bad; vendor preset: disabled)
Active: active (running) since Tue 2018-03-27 21:12:07 CST; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 21092 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysql.service
├─21097 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/VM_83_223_centos.pid
└─21204 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql ...
Mar 27 21:12:06 VM_83_223_centos systemd[1]: Starting LSB: start and stop MySQL...
Mar 27 21:12:06 VM_83_223_centos mysql[21092]: Starting MySQL.Logging to '/usr/local/mysql/data/VM_83_223_centos.err'.
Mar 27 21:12:07 VM_83_223_centos mysql[21092]: SUCCESS!
Mar 27 21:12:07 VM_83_223_centos systemd[1]: Started LSB: start and stop MySQL.
[root@VM_83_223_centos support-files]# systemctl enable mysql.service
mysql.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysql on
[root@VM_83_223_centos support-files]#
[root@VM_83_223_centos support-files]# /sbin/chkconfig mysql on
[root@VM_83_223_centos support-files]#
[root@VM_83_223_centos support-files]# chkconfig --list mysql
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
9、設定root使用者的密碼
[root@VM_83_223_centos support-files]# /usr/local/mysql/bin/mysqladmin -u root password 'qcloud@2018'
Warning: Using a password on the command line interface can be insecure.
10、登入授權
[root@VM_83_223_centos support-files]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> select version();
+-----------+
| version() |
+-----------+
| 5.6.36 |
+-----------+
1 row in set (0.00 sec)
mysql> select host,user from mysql.user;
+---------------------+------+
| host | user |
+---------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | |
| localhost | root |
| vm\_83\_223\_centos | |
| vm\_83\_223\_centos | root |
+---------------------+------+
6 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'qcloud@2018' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> select host,user from mysql.user;
+---------------------+------+
| host | user |
+---------------------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | |
| localhost | root |
| vm\_83\_223\_centos | |
| vm\_83\_223\_centos | root |
+---------------------+------+
7 rows in set (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
作者:SEian.G(苦練七十二變,笑對八十一難)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2152429/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- codis安裝 (java 安裝 + zookeeper 安裝 + go 安裝 + codis 安裝JavaGo
- 安裝npm 解除安裝npm 安裝apidocNPMAPI
- mysql安裝 (yum 安裝)MySql
- MMM安裝、MHA安裝
- mysql安裝------RPM包安裝及解除安裝MySql
- oracle安裝:OUI安裝Oracle(圖形介面安裝)OracleUI
- ffmpeg安裝之mac安裝Mac
- docker安裝及解除安裝Docker
- 02 安裝git、安裝TortoiseGitGit
- Ubuntu解除安裝和安裝Ubuntu
- Orace RAC安裝-DNS安裝DNS
- caffe安裝系列——安裝OpenCVOpenCV
- SPARK 安裝之scala 安裝Spark
- mac 安裝opencv homebrew安裝MacOpenCV
- Oracle 安裝與解除安裝Oracle
- solaris mysql 安裝 解除安裝MySql
- BiocManager安裝,devtools安裝dev
- JDK安裝和解除安裝JDK
- 安裝HomeBrew提示已安裝並無法解除安裝
- SQL Server 2012 安裝——安裝 OR 解除安裝SQLServer
- win10安裝版怎麼安裝_安裝版win10安裝教程Win10
- mysql安裝-----二進位制包安裝及解除安裝MySql
- cocoapods安裝/解除安裝/使用
- Mac Redis安裝與解除安裝MacRedis
- [ 安裝 ] Zeppelin安裝步驟!
- Ubuntu安裝和解除安裝mongodbUbuntuMongoDB
- linux 安裝yum 安裝phpLinuxPHP
- [雲原生]Docker - 安裝&解除安裝Docker
- JDK的安裝與解除安裝JDK
- selenium 安裝與 chromedriver安裝Chrome
- ORACLE TEXT安裝與解除安裝Oracle
- Centos 安裝yum,安裝ansibleCentOS
- zabbix安裝—–nginx安裝和配置Nginx
- LAMP原始碼安裝+wordpress安裝LAMP原始碼
- mysql非安裝包安裝教程MySql
- kratos安裝及依賴安裝
- Linux安裝解除安裝MySQLLinuxMySql
- MySQL 5.7 原始碼安裝、Yum倉庫安裝、RPM安裝、二進位制安裝MySql原始碼