MySQL的簡單使用

#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

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市崎苗,隨后出現(xiàn)的幾起案子狐粱,更是在濱河造成了極大的恐慌舀寓,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,525評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件肌蜻,死亡現(xiàn)場離奇詭異互墓,居然都是意外死亡,警方通過查閱死者的電腦和手機蒋搜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,203評論 3 395
  • 文/潘曉璐 我一進店門篡撵,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人豆挽,你說我怎么就攤上這事育谬。” “怎么了祷杈?”我有些...
    開封第一講書人閱讀 164,862評論 0 354
  • 文/不壞的土叔 我叫張陵斑司,是天一觀的道長。 經(jīng)常有香客問我但汞,道長宿刮,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,728評論 1 294
  • 正文 為了忘掉前任私蕾,我火速辦了婚禮僵缺,結果婚禮上,老公的妹妹穿的比我還像新娘踩叭。我一直安慰自己磕潮,他們只是感情好,可當我...
    茶點故事閱讀 67,743評論 6 392
  • 文/花漫 我一把揭開白布容贝。 她就那樣靜靜地躺著自脯,像睡著了一般。 火紅的嫁衣襯著肌膚如雪斤富。 梳的紋絲不亂的頭發(fā)上膏潮,一...
    開封第一講書人閱讀 51,590評論 1 305
  • 那天,我揣著相機與錄音满力,去河邊找鬼焕参。 笑死,一個胖子當著我的面吹牛油额,可吹牛的內容都是我干的叠纷。 我是一名探鬼主播,決...
    沈念sama閱讀 40,330評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼潦嘶,長吁一口氣:“原來是場噩夢啊……” “哼涩嚣!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,244評論 0 276
  • 序言:老撾萬榮一對情侶失蹤缓艳,失蹤者是張志新(化名)和其女友劉穎校摩,沒想到半個月后看峻,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體阶淘,經(jīng)...
    沈念sama閱讀 45,693評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,885評論 3 336
  • 正文 我和宋清朗相戀三年互妓,在試婚紗的時候發(fā)現(xiàn)自己被綠了溪窒。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,001評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡冯勉,死狀恐怖澈蚌,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情灼狰,我是刑警寧澤宛瞄,帶...
    沈念sama閱讀 35,723評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站交胚,受9級特大地震影響份汗,放射性物質發(fā)生泄漏。R本人自食惡果不足惜蝴簇,卻給世界環(huán)境...
    茶點故事閱讀 41,343評論 3 330
  • 文/蒙蒙 一杯活、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧熬词,春花似錦旁钧、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,919評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至颜矿,卻和暖如春寄猩,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背或衡。 一陣腳步聲響...
    開封第一講書人閱讀 33,042評論 1 270
  • 我被黑心中介騙來泰國打工焦影, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人封断。 一個月前我還...
    沈念sama閱讀 48,191評論 3 370
  • 正文 我出身青樓斯辰,卻偏偏與公主長得像,于是被迫代替她去往敵國和親坡疼。 傳聞我的和親對象是個殘疾皇子彬呻,可洞房花燭夜當晚...
    茶點故事閱讀 44,955評論 2 355

推薦閱讀更多精彩內容