#vi /etc/sysconfig/network-scripts/ifcfg-eth0 修改ip
#service network restart? 重啟網(wǎng)卡
# yum install -y wget? ? 安裝wget
#yum clean all
#yum makecache
#cd /usr/local/src/? 到/usr/local/src/
#wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 下載mysql
#tar zxvf mysql-5.5.53-linux2.6-x86_64.tar.gz? ? 解壓 mysql文件
#useradd -s /sbin/nologin -M mysql? ? 創(chuàng)建 mysql用戶
# mv mysql-5.5.53-linux2.6-x86_64 /usr/local/mysql 把文件移動到/usr/local/mysql
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 這個文件是重新命名的
#cd /usr/local/mysql
# ls? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 顯示其目錄下的文件
bin? ? ? data? include? ? ? ? lib? mysql-test? scripts? sql-bench
COPYING? docs? INSTALL-BINARY? man? README? ? ? share? ? support-files
# mkdir -p /data/mysql/? ? ? ? ? ? ? 創(chuàng)建一個目錄
#chown -R mysql:mysql /data/mysql? ? 修改權限,(且目錄下文件的權限一起修改)
# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql? 初始化谅河,提示安裝libaio
--------------------------------------------------------------------------------
Installing MySQL system tables...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
Installation of system tables failed!? Examine the logs in
/data/mysql for more information.
You can try to start the mysqld daemon with:
? ? shell> ./bin/mysqld --skip-grant &
and use the command line tool ./bin/mysql
to connect to the mysql database and look at the grant tables:
? ? shell> ./bin/mysql -u root mysql
? ? mysql> show tables
Try 'mysqld --help' if you have problems with paths.? Using --log
gives you a log in /data/mysql that may be helpful.
Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS.? Another information source are the
MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before submitting a bug report
at http://bugs.mysql.com/
--------------------------------------------------------------------------
#yum install -y libaio? 安裝 libaio
#./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
初始化沒有mysql
# echo $? 提示0 證明沒有錯誤
0
[root@localhost mysql]# cp support-files/my-
my-huge.cnf? ? ? ? ? ? my-large.cnf? ? ? ? ? ? my-small.cnf
my-innodb-heavy-4G.cnf? my-medium.cnf
=================================================================================
[root@localhost mysql]# cp support-files/my-large.cnf? /etc/my.cnf 把my-large.cnf 拷貝到 /etc/my.cnf 下? mysql的配置文件? ?
cp: overwrite `/etc/my.cnf'? y? ? ? ? ? ? ? ? ? (因為有了這文件)確定覆蓋此文件
#cd /usr/local/mysql/? (我所安裝的mysql的路徑)
[root@localhost mysql]# ls? 顯示
bin? ? ? data? include? ? ? ? lib? mysql-test? scripts? sql-bench
COPYING? docs? INSTALL-BINARY? man? README? ? ? share? ? support-files
[root@localhost mysql]# cp support-files/mysql.server? /etc/init.d/mysqld? ? /etc/init.d/? 目錄下面 是需要開機啟動的服務的啟動文件
support-files/mysql.server【啟動文件】? /etc/init.d/mysqld
(把mysql服務啟動文件復制到/etc/init.d/mysqld)
mysql]# chmod 755 /etc/init.d/mysqld 給以mysqld文件
【root用戶可以可讀可寫可執(zhí)行 root用戶組和其他用戶可以查看文件內容咱旱,并執(zhí)行這個文件】
# vi /etc/init.d/mysqld 編輯這個文件
basedir=/usr/local/mysql
datadir=/data/mysql
[root@localhost mysql]# chkconfig --add mysqld? 把MySQL添加到系統(tǒng)服務中
[root@localhost mysql]# chkconfig mysqld on? 關閉mysql
【[root@localhost mysql]# chkconfig mysqld start ?绷耍?吐限??褂始?】
可知是哪里錯誤了诸典?
# ps aux |grep mysql? ? 查看狀態(tài)
root? ? ? 2104? 0.0? 0.0 103244? 860 pts/0? ? S+? 22:52? 0:00 grep mysql
#service mysqld start? 啟動MySQL? 前者命令敲錯了
Starting MySQL.... SUCCESS!
[root@localhost mysql]# ps aux |grep mysql
root? ? ? 2132? 0.0? 0.1? 11304? 1500 pts/0? ? S? ? 23:05? 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql? ? 2424? 0.4? 9.1 747416 93456 pts/0? ? Sl? 23:05? 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
root? ? ? 2449? 0.0? 0.0 103244? 864 pts/0? ? S+? 23:06? 0:00 grep mysql
在Windows 命令行下 telnet? 192.168.11.136 3306
#netstat -tan 查看端口命令
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address? ? ? ? ? ? ? Foreign Address? ? ? ? ? ? State
tcp? ? ? ? 0? ? ? 0 0.0.0.0:22? ? ? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? ? ? LISTEN
tcp? ? ? ? 0? ? ? 0 127.0.0.1:25? ? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? ? ? LISTEN
tcp? ? ? ? 0? ? ? 0 0.0.0.0:3306? ? ? ? ? ? ? ? 0.0.0.0:*? ? ? ? ? ? ? ? ? LISTEN
tcp? ? ? ? 0? ? 64 192.168.11.136:22? ? ? ? ? 192.168.11.107:49910? ? ? ? ESTABLISHED
tcp? ? ? ? 0? ? ? 0 :::22? ? ? ? ? ? ? ? ? ? ? :::*? ? ? ? ? ? ? ? ? ? ? ? LISTEN
tcp? ? ? ? 0? ? ? 0 ::1:25? ? ? ? ? ? ? ? ? ? ? :::*? ? ? ? ? ? ? ? ? ? ? ? LISTEN
[root@localhost mysql]# service mysqld restart 重新啟動MySQL
Shutting down MySQL. SUCCESS!
Starting MySQL.. SUCCESS!
[root@localhost mysql]# ss -tan 查看端口
State? ? ? Recv-Q Send-Q? ? ? ? ? ? ? ? ? ? Local Address:Port? ? ? ? ? ? ? ? ? ? ? Peer Address:Port
LISTEN? ? ? 0? ? ? 128? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::22? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::*
LISTEN? ? ? 0? ? ? 128? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:22? 任何人都可以防火墻端口開著? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:*
LISTEN? ? ? 0? ? ? 100? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ::1:25? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :::*
LISTEN? ? ? 0? ? ? 100? ? ? ? ? ? ? ? ? ? ? ? ? ? 127.0.0.1:25? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:*
LISTEN? ? ? 0? ? ? 50? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:3306? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *:*
ESTAB? ? ? 0? ? ? 64? ? ? ? ? ? ? ? ? ? ? ? 192.168.11.136:22? ? ? ? ? ? ? ? ? ? ? 192.168.11.107:49910