下面一起來(lái)了解下MySQL安裝的簡(jiǎn)單教程,相信大家看完肯定會(huì)受益匪淺,文字在精不在多,希望MYSQL安裝的簡(jiǎn)單教程這篇短內(nèi)容是你想要的。
成都創(chuàng)新互聯(lián)專(zhuān)注于企業(yè)全網(wǎng)營(yíng)銷(xiāo)推廣、網(wǎng)站重做改版、進(jìn)賢網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5網(wǎng)站設(shè)計(jì)、成都商城網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性?xún)r(jià)比高,為進(jìn)賢等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
root@localhost ~]# mysql -uroot -p
Enter password:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db2 |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db
MariaDB [mysql]> select user from user;
+------+
| user |
+------+
| lee |
| root |
| root |
| root |
+------+
4 rows in set (0.00 sec)
MariaDB [mysql]> select * from user;
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+
MariaDB [mysql]> desc user;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(16) | NO | PRI | | |
| Password | char(41) | NO | | | |
| Select_priv | enum('N','Y') | NO | | N
yum install -y mariadb-server
systemctl start mariadb
mysql
netstat -antlpe | grep mysql
vim /etc/my.cnf
[mysqld]模塊下添加
skip-networking=1 ##關(guān)閉數(shù)據(jù)庫(kù)在網(wǎng)絡(luò)上開(kāi)啟的端口,加鎖 防止別人進(jìn)攻 這是端口看不到了
systemctl restart mariadb
netstat -antlpe | grep mysql
mysql
mysql_secure_installation 設(shè)置密碼 匿名用戶(hù)不能登陸 遠(yuǎn)程不能登陸等
mysql -uroot -p
redhat 密碼
MariaDB [(none)]> create database westos;
Query OK, 1 row affected (0.00 sec)
MariaDB [westos]> create table linux(
-> username varchar(15) not null,
-> password varchar(15) not null
-> );
Query OK, 0 rows affected (0.04 sec)
MariaDB [westos]> show tables;
+------------------+
| Tables_in_westos |
+------------------+
| linux |
+------------------+
1 row in set (0.00 sec)
MariaDB [westos]> insert into linux values ('user1','123');
Query OK, 1 row affected (0.01 sec)
MariaDB [westos]> insert into linux values ('user2',password('123'));
Query OK, 1 row affected, 1 warning (0.04 sec) 對(duì)密碼進(jìn)行加密
MariaDB [westos]> select * from linux;
+----------+-----------------+
| username | password |
+----------+-----------------+
| user1 | 123 |
| user2 | *23AE809DDACAF9 |
+----------+-----------------+
2 rows in set (0.00 sec)
MariaDB [westos]> update linux set password=password('234') where username='user1';
Query OK, 1 row affected, 1 warning (0.61 sec)
Rows matched: 1 Changed: 1 Warnings: 1
MariaDB [westos]> delete from linux where username='user1';
Query OK, 1 row affected (0.02 sec)
MariaDB [westos]> alter table linux add age varchar(4);
Query OK, 1 row affected (0.11 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [westos]> select * from linux;
+----------+-----------------+------+
| username | password | age |
+----------+-----------------+------+
| user2 | *23AE809DDACAF9 | NULL |
+----------+-----------------+------+
1 row in set (0.00 sec)
MariaDB [westos]> alter table linux drop age;
Query OK, 1 row affected (0.40 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [westos]> select * from linux;
+----------+-----------------+
| username | password |
+----------+-----------------+
| user2 | *23AE809DDACAF9 |
+----------+-----------------+
1 row in set (0.00 sec)
MariaDB [westos]> alter table linux add age varchar(5) after username;
Query OK, 1 row affected (0.10 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [westos]> select * from linux;
+----------+------+-----------------+
| username | age | password |
+----------+------+-----------------+
| user2 | NULL | *23AE809DDACAF9 |
MariaDB [westos]> alter table linux drop age;
MariaDB [westos]> delete from linux where username='user1';
Query OK, 0 rows affected (0.00 sec)
MariaDB [westos]> drop table linux;
Query OK, 0 rows affected (0.32 sec)
MariaDB [westos]> drop database westos;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db2 |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
Query OK, 1 row affected (0.41 sec)
[root@localhost ~]# mysqldump -u root -predhat westos
[root@localhost ~]# mysqldump -u root -predhat westos > /mnt/westos.sql
[root@localhost ~]# mysql -uroot -predhat -e "drop database westos;"
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 5.5.35-MariaDB MariaDB Server
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db2 |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)
MariaDB [(none)]> mysql -uroot -predhat -e "create database westos;"
-> Ctrl-C -- exit!
Aborted
[root@localhost ~]# mysql -uroot -predhat -e "create database westos;"
[root@localhost ~]# mysql -uroot -predhat westos< /mnt/westos.sql
[root@localhost ~]# mysql -uroot -predhat -e "select * from westos.linux;"
+----------+----------+
| username | password |
+----------+----------+
| user1 | 123 |
| user2 | 456 |
+----------+----------+
MariaDB [(none)]> create user lee@localhost identified by 'lee';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant insert,update,delete,select on westos.linux to lee@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant select on westos.* to lee@'%';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show grants for lee@'%';
+----------------------------------------------------------------------------------------------------+
| Grants for lee@% |
+----------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'lee'@'%' IDENTIFIED BY PASSWORD '*28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96' |
| GRANT SELECT ON `westos`.* TO 'lee'@'%' |
+----------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> revoke delete on westos.linux from lee@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> drop user lee@'localhost';
Query OK, 0 rows affected (0.00 sec)
[root@localhost ~]# mysqladmin -uroot -pwestos password redhat
[root@localhost ~]# systemctl stop mariadb.service
[root@localhost ~]# ps aux | grep mysql
root 5724 0.0 0.0 112640 980 pts/1 S+ 01:53 0:00 grep --color=auto mysql
[root@localhost ~]# mysqld_safe --skip-grant-tables &
[1] 5744
[root@localhost ~]# killall -9 mysqld_safe
[1]+ Killed mysqld_safe --skip-grant-tables
[root@localhost ~]# ps aux | grep mysql
[root@localhost ~]# kill -9 6019
[root@localhost ~]# ps aux | grep mysql
root 6083 0.0 0.0 112640 980 pts/1 R+ 02:02 0:00 grep --color=auto mysql
[root@localhost ~]# systemctl start mariadb
@@@@@@@@@@ 用網(wǎng)頁(yè) 鼠標(biāo)點(diǎn)一點(diǎn)便可建立數(shù)據(jù)庫(kù) 插入表 刪除表數(shù)據(jù)庫(kù)等等
lftp 172.25.254.250:/pub/docs/software> get phpMyAdmin-3.4.0-all-languages.tar.bz2
4548030 bytes transferred
lftp 172.25.254.250:/pub/docs/software> quit
[root@localhost ~]# ls
anaconda-ks.cfg lala.py Public
backup.dump linux.dump Templates
Desktop Music Videos
Documents phpMyAdmin-3.4.0-all-languages.tar.bz2 westos.dump
Downloads Pictures
[root@localhost ~]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html/
[root@localhost ~]# ls
anaconda-ks.cfg lala.py Public
backup.dump linux.dump Templates
Desktop Music Videos
Documents phpMyAdmin-3.4.0-all-languages.tar.bz2 westos.dump
Downloads Pictures
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
phpMyAdmin-3.4.0-all-languages
[root@localhost html]# mv phpMyAdmin-3.4.0-all-languages/ mysqladmin
ot@localhost html]# ls
mysqladmin
[root@localhost html]# cd mysqladmin/
[root@localhost mysqladmin]# ls
browse_foreigners.php main.php server_status.php
bs_disp_as_mime_type.php navigation.php server_synchronize.php
bs_play_media.php phpdoctor.ini server_variables.php
........
[root@localhost mysqladmin]# cp -p config.sample.inc.php config.inc.php
[root@localhost mysqladmin]# vim config.inc.php
17 $cfg['blowfish_secret'] = 'mysql'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
[root@localhost mysqladmin]# systemctl restart httpd
測(cè)試:
訪問(wèn) http://172.25.254.170/mysqladmin
這是會(huì)看到phpMyAdmin 界面 這個(gè)時(shí)候選擇中文root redhat
可以新建數(shù)據(jù)庫(kù) 表 插入 刪除表 等等
################ mysql ######################################
數(shù)據(jù)庫(kù)時(shí)有好多張表組成
yum install -y mariadb-server
systemctl start mariadb
mysql
netstat -antlpe | grep mysql 會(huì)看到3306端口
vim /etc/my.cnf
[mysqld]模塊下添加
skip-networking=1 ##關(guān)閉數(shù)據(jù)庫(kù)在網(wǎng)絡(luò)上開(kāi)啟的端口,加鎖 防止別人進(jìn)攻 這是端口看
不到了 這樣別人就不能***修改數(shù)據(jù)庫(kù)上的數(shù)據(jù)了 1表有效
systemctl restart mariadb
netstat -antlpe | grep mysql 這時(shí)看不到3306端口了
mysql_secure_installation 設(shè)置root密碼 匿名用戶(hù)不能登陸 遠(yuǎn)程不能登陸
mysql -uroot -p
redhat 輸入mysql的密碼
@@@@@@@@@@@@ 數(shù)據(jù)庫(kù)的基本sql語(yǔ)句操作 @@@@@@@@@@@@@@@@
1 登陸
mysql -uroot -predhat
2 查詢(xún)
show databases; 顯示數(shù)據(jù)庫(kù)
use mysql; 進(jìn)入mysql數(shù)據(jù)庫(kù)
show tables; 顯示當(dāng)前庫(kù)中表的名稱(chēng)
select * from user; 查詢(xún)user表中的所有內(nèi)容(*可以用此表中的任何字段表示)
desc user; 查詢(xún)user表的結(jié)構(gòu)(顯示所有字段的名稱(chēng))
3數(shù)據(jù)庫(kù)及表的建立
create database westos 創(chuàng)建westos庫(kù)
create table linux( 創(chuàng)建linux表 并且linux表含有兩個(gè)字段username password
username varchar(15) not null, username字段 字符長(zhǎng)度最大15個(gè),并且不能為空
password varchar(15) not null
);
insert into linux values ('user1','123'); 向linux表中插入數(shù)據(jù),username字段的數(shù)據(jù)為user1
insert into linux values ('user2',password('123')); 插入password字段的數(shù)據(jù)是用password加密過(guò)的
4更新數(shù)據(jù)庫(kù)信息
update linux set password=password('passwd2') where username='user1';
更新user1的密碼
delete from linux where username='user1'; 刪除user1信息
alter table linux add age varchar(4); 添加age字段到linux表的最后一列
alter table linux add age varchar(5) after name; 添加age字段在name字段之后
alter table linux drop age; 刪除age字段
5刪除數(shù)據(jù)庫(kù)
delete from linux where username='user1'; 刪除user1的數(shù)據(jù)從linux表中
drop table linux; 刪除linux表
drop database westos; 刪除westos數(shù)據(jù)庫(kù)
6 數(shù)據(jù)庫(kù)的備份
mysqldump -u root -predhat --all-database 備份所有表中的所有數(shù)據(jù)
mysqldump -u root -predhat --all-database --no-database --no-data 備份所有表但不備份數(shù)據(jù)
mysqldump -u root -predhat westos 備份westos數(shù)據(jù)庫(kù)
mysqldump -u root -predhat westos > /mnt/westos.sql
備份westos數(shù)據(jù)庫(kù)并把數(shù)據(jù)保存到westos.sql中
mysqldump -u root -predhat westos linux > /mnt/linux.sql
備份mysql中的linux表
mysql -uroot -predhat -e "create database westos;" 建立westos庫(kù)
mysql -uroot -predhat westos < /mnt/westos.sql 把數(shù)據(jù)導(dǎo)入westos庫(kù)
7用戶(hù)授權(quán) 必須用超級(jí)用戶(hù)
create user lee@localhost identified by 'lee'; 建立用戶(hù)lee,此用戶(hù)只能通過(guò)本機(jī)登陸
create user lee@'%' identified by 'lee'; 建立用戶(hù)lee,此用戶(hù)可以通過(guò)網(wǎng)絡(luò)登錄
grant insert,update,delect,select on westos.test to lee@localhost;
用戶(hù)授權(quán) 授權(quán)westos數(shù)據(jù)庫(kù)的test表可以通過(guò)localhost主機(jī)登陸lee用戶(hù)
grant select on westos.* to lee@'%';
show grants for lee@'%' 查看用戶(hù)授權(quán)
show grants for lee@localhost
revoke delete on westos.test from lee@localhost; 去除用戶(hù)授權(quán)權(quán)力
drop user lee@'%'; 刪除用戶(hù)
8修改密碼
mysqladmin -uroot -predhat password lee
忘記超級(jí)用戶(hù)密碼時(shí)的操作
mysqld_safe --skip-grant-tables & 開(kāi)啟mysql登陸接口并忽略授權(quán)表
mysql 直接不用密碼可以登陸
update mysql.user set Password=password('123') where User='root';
更新超級(jí)用戶(hù)密碼信息
ps aux | grep mysql 過(guò)濾mysql的所有進(jìn)程并結(jié)束這些進(jìn)程
kill -9 mysqlpid
systemctl start mariadb 重新開(kāi)啟mysql
mysql -uroot -p123 登陸測(cè)試
1安裝
yum install -y httpd php php-mysql
systemctl start httpd
systemctl enable httpd
systemctl stop firewalld
systemctl disable firewalld
下載 phpMyAdmin-3.4.0-all-languages.tar.bz2
tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html解壓到指定目錄
cd /var/www/html
mv phpMyAdmin-3.4.0-all-languages mysqladmin
cd mysqladmin
cp -p config.sample.inc.php config.inc.php
vim config.inc.php
17 $cfg['blowfish_secret']= 'mysql'; /* YOU MUST FILL IN THIS FOR COOKIEAUTH! */
systemctl restrt httpd
測(cè)試:
訪問(wèn)http://172.25.254.170/mysqladmin
會(huì)看到phpadmin界面 用鼠標(biāo)點(diǎn)一點(diǎn)即可創(chuàng)建數(shù)據(jù)庫(kù) 添加字段 刪除表等 同時(shí)還會(huì)同步到命令行中 用命令可以在命令行中看到 相當(dāng)于用命令創(chuàng)建 刪除增添 但是phpmyadmin方便快捷
看完MYSQL安裝的簡(jiǎn)單教程這篇文章后,很多讀者朋友肯定會(huì)想要了解更多的相關(guān)內(nèi)容,如需獲取更多的行業(yè)信息,可以關(guān)注我們的行業(yè)資訊欄目。
當(dāng)前名稱(chēng):MYSQL安裝的簡(jiǎn)單教程
新聞來(lái)源:http://www.rwnh.cn/article38/igjppp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、小程序開(kāi)發(fā)、網(wǎng)站排名、品牌網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)