mysql安裝記
網上有很多介紹mysql安裝的文件,不過總感覺說得不夠詳細徹底,今天又有機會安裝mysql了,現將步驟記之,希望對mysql初學者有所幫忙 (hehe,我就是一個地道的初學者)
一.環境
[root@TEST run]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 3 (Taroon Update 8)
[root@TEST run]# uname -a
Linux TEST 2.4.21-47.ELsmp #1 SMP Wed Jul 5 20:38:41 EDT 2006 i686 i686 i386 GNU/Linux
mysql版本是 5.0.26-standard
二.安裝
1.建立mysql使用者和mysql組
[root@TEST home]# groupadd mysql
[root@TEST home]# useradd -g mysql mysql
2.將mysql安裝包解壓到指定目錄
[root@TEST home]# tar -zxvf mysql-standard-5.0.26-linux-i686.tar.gz -C /usr/local/
3.如果以前沒有安裝過mysql,就必須建立mysql授權表
[root@TEST home]# cd /usr/local/
[root@TEST local]# cd mysql
[root@TEST mysql]# scripts/mysql_install_db --user=mysql
4.修改檔案屬組及擁有者許可權
[root@TEST mysql]# pwd
/usr/local/mysql
[root@TEST mysql]# ll
total 92
drwxr-xr-x 2 503 users 4096 Oct 5 2006 bin
-rwxr-xr-x 1 503 users 801 Oct 5 2006 configure
-rw-r--r-- 1 503 users 19071 Oct 4 2006 COPYING
drwxr-x--- 4 503 users 4096 Oct 5 2006 data
drwxr-xr-x 2 503 users 4096 Oct 5 2006 docs
-rw-r--r-- 1 503 users 5806 Oct 5 2006 EXCEPTIONS-CLIENT
drwxr-xr-x 2 503 users 4096 Oct 5 2006 include
-rw-r--r-- 1 503 users 7752 Oct 5 2006 INSTALL-BINARY
drwxr-xr-x 2 503 users 4096 Oct 5 2006 lib
drwxr-xr-x 4 503 users 4096 Oct 5 2006 man
drwxr-xr-x 7 503 users 4096 Oct 5 2006 mysql-test
-rw-r--r-- 1 503 users 1380 Oct 4 2006 README
drwxr-xr-x 2 503 users 4096 Oct 5 2006 scripts
drwxr-xr-x 3 503 users 4096 Oct 5 2006 share
drwxr-xr-x 5 503 users 4096 Oct 5 2006 sql-bench
drwxr-xr-x 2 503 users 4096 Oct 5 2006 support-files
drwxr-xr-x 2 503 users 4096 Oct 5 2006 tests
[root@TEST mysql]# chown -R root . -------把當前目錄下所有檔案的擁有者修改為root
[root@TEST mysql]# ll
total 92
drwxr-xr-x 2 root users 4096 Oct 5 2006 bin
-rwxr-xr-x 1 root users 801 Oct 5 2006 configure
-rw-r--r-- 1 root users 19071 Oct 4 2006 COPYING
drwxr-x--- 4 root users 4096 Oct 5 2006 data
drwxr-xr-x 2 root users 4096 Oct 5 2006 docs
-rw-r--r-- 1 root users 5806 Oct 5 2006 EXCEPTIONS-CLIENT
drwxr-xr-x 2 root users 4096 Oct 5 2006 include
-rw-r--r-- 1 root users 7752 Oct 5 2006 INSTALL-BINARY
drwxr-xr-x 2 root users 4096 Oct 5 2006 lib
drwxr-xr-x 4 root users 4096 Oct 5 2006 man
drwxr-xr-x 7 root users 4096 Oct 5 2006 mysql-test
-rw-r--r-- 1 root users 1380 Oct 4 2006 README
drwxr-xr-x 2 root users 4096 Oct 5 2006 scripts
drwxr-xr-x 3 root users 4096 Oct 5 2006 share
drwxr-xr-x 5 root users 4096 Oct 5 2006 sql-bench
drwxr-xr-x 2 root users 4096 Oct 5 2006 support-files
drwxr-xr-x 2 root users 4096 Oct 5 2006 tests
[root@TEST mysql]# chown -R mysql data ---------- 把data目錄擁有者修改為mysql
[root@TEST mysql]# ll
total 92
drwxr-xr-x 2 root users 4096 Oct 5 2006 bin
-rwxr-xr-x 1 root users 801 Oct 5 2006 configure
-rw-r--r-- 1 root users 19071 Oct 4 2006 COPYING
drwxr-x--- 4 mysql users 4096 Oct 5 2006 data
drwxr-xr-x 2 root users 4096 Oct 5 2006 docs
-rw-r--r-- 1 root users 5806 Oct 5 2006 EXCEPTIONS-CLIENT
drwxr-xr-x 2 root users 4096 Oct 5 2006 include
-rw-r--r-- 1 root users 7752 Oct 5 2006 INSTALL-BINARY
drwxr-xr-x 2 root users 4096 Oct 5 2006 lib
drwxr-xr-x 4 root users 4096 Oct 5 2006 man
drwxr-xr-x 7 root users 4096 Oct 5 2006 mysql-test
-rw-r--r-- 1 root users 1380 Oct 4 2006 README
drwxr-xr-x 2 root users 4096 Oct 5 2006 scripts
drwxr-xr-x 3 root users 4096 Oct 5 2006 share
drwxr-xr-x 5 root users 4096 Oct 5 2006 sql-bench
drwxr-xr-x 2 root users 4096 Oct 5 2006 support-files
drwxr-xr-x 2 root users 4096 Oct 5 2006 tests
[root@TEST mysql]# chgrp -R mysql . ----------把當前目當下所有檔案的屬組修改為mysql
[root@TEST mysql]# ll
total 92
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 bin
-rwxr-xr-x 1 root mysql 801 Oct 5 2006 configure
-rw-r--r-- 1 root mysql 19071 Oct 4 2006 COPYING
drwxr-x--- 4 mysql mysql 4096 Oct 5 2006 data
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 docs
-rw-r--r-- 1 root mysql 5806 Oct 5 2006 EXCEPTIONS-CLIENT
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 include
-rw-r--r-- 1 root mysql 7752 Oct 5 2006 INSTALL-BINARY
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 lib
drwxr-xr-x 4 root mysql 4096 Oct 5 2006 man
drwxr-xr-x 7 root mysql 4096 Oct 5 2006 mysql-test
-rw-r--r-- 1 root mysql 1380 Oct 4 2006 README
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 scripts
drwxr-xr-x 3 root mysql 4096 Oct 5 2006 share
drwxr-xr-x 5 root mysql 4096 Oct 5 2006 sql-bench
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 support-files
drwxr-xr-x 2 root mysql 4096 Oct 5 2006 tests
5.啟動mysql(可惜出錯了-_-)
[root@TEST mysql]# bin/mysqld_safe --user=mysql &
[1] 11222
[root@TEST mysql]# Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/run/mysqld/mysqld.pid
080410 15:08:06 mysqld ended
[1]+ Done bin/mysqld_safe --user=mysql
三.解決安裝錯誤
1.根據提示找到日誌
[root@TEST mysql]# pwd
/var/lib/mysql
[root@TEST mysql]# ls
ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock TEST.err test
[root@TEST mysql]# cat TEST.err
080410 15:18:23 mysqld started
080410 15:18:23 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
080410 15:18:23 InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 36808.
InnoDB: Doing recovery: scanned up to log sequence number 0 43655
080410 15:18:23 InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
080410 15:18:24 InnoDB: Started; log sequence number 0 43655
080410 15:18:24 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
080410 15:18:24 [ERROR] Can't start server: can't create PID file: No such file or directory
080410 15:18:24 mysqld ended
據此推斷,可能是mysql 啟動時會向此資料夾內寫一些東西,但 mysql 的程式使用者mysql 卻沒有許可權寫,導致mysql 無法啟動,用touch /var/run/mysqld/mysqld.pid 命令建立mysql 所需要檔案,chown -R mysql:mysql/var/run/mysqld將/var/run/mysqld 的目錄許可權轉給 mysql.
2.解僱方法
[root@TEST mysql]# cd /var/run/
[root@TEST run]# mkdir mysqld
[root@TEST run]# touch mysqld/mysqld.pid
[root@TEST run]# chown -R mysql:mysql /var/run/mysqld
3.再嘗試啟動mysql
[root@TEST mysql]# bin/mysqld_safe --user=mysql &
[1] 11723
[root@TEST mysql]# Starting mysqld daemon with databases from /var/lib/mysql
4.測試mysql
[root@TEST mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.26-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.03 sec)
到此安裝成功
如要轉載,請註明出處
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7364032/viewspace-234400/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mysql學習筆記(安裝篇)MySql筆記
- MySQL 5.7.24安裝MySQL審計外掛小記MySql
- docker筆記18-案例-安裝mysqlDocker筆記MySql
- 安裝mysqlMySql
- MySQL安裝MySql
- mysql 安裝MySql
- Linux安裝解除安裝MySQLLinuxMySql
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- 【MySQL安裝】Linux下安裝MySQL(預編譯)MySqlLinux編譯
- mysql-8.4.0解壓版安裝記錄MySql
- 【推薦 - glibc安裝】MySQL - 安裝MySql
- MySQL 8.0.21下載安裝教程及Navicat for MySQL安裝MySql
- 安裝mysql和mysql workbenchMySql
- RockyLinux安裝MySQLLinuxMySql
- ubuntu安裝MySQLUbuntuMySql
- Debian安裝MySQLMySql
- helm安裝mysqlMySql
- Ubuntu 安裝 mysqlUbuntuMySql
- Linux安裝MySQLLinuxMySql
- Docker 安裝mysqlDockerMySql
- MySQL安裝流程MySql
- Windows安裝mysqlWindowsMySql
- docker安裝mysqlDockerMySql
- macbook 安裝 mysqlMacMySql
- MySQL 的安裝MySql
- MySQL安裝配置MySql
- docker 安裝 mysqlDockerMySql
- MYSQL免安裝MySql
- mysql window 安裝MySql
- mysql yum 安裝MySql
- MySQL安裝-未完MySql
- MySQL 8.0 安裝MySql
- Ansible安裝mysqlMySql
- mysql安裝 for LinuxMySqlLinux
- mysql安裝(rpm)MySql
- mysql安裝教程8.0.26 安裝mysql的步驟和方法MySql
- MySQL:mysql5.7解壓版安裝與解除安裝MySql
- CentOS7安裝php、安裝MySqlCentOSPHPMySql
- Linux-Ubuntu-mysql-安裝&解除安裝LinuxUbuntuMySql