日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql linux 安装部署,linux之MySQL安装部署(示例代码)

發布時間:2024/10/14 数据库 73 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql linux 安装部署,linux之MySQL安装部署(示例代码) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MySQL安裝配置步驟:

1.??? 進入/home/oldboy/tools 執行上傳mysql數據庫指令并創建一個mysql用戶

#rz -y上傳壓縮包

[[email?protected] tools]# cd /home/oldboy/tools/

[[email?protected] tools]# useradd -s /sbin/nologin? -M mysql

mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

2.??? 解壓mysql安裝包

[[email?protected] tools]# tar xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

mysql-5.6.35-linux-glibc2.5-x86_64??????? mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

3.??? 移動解壓出來的mysql目錄到指定目錄

#沒有這個目錄則創建?????? mkdir -p /application

[[email?protected] tools]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /application/mysql-5.6.35

[[email?protected] tools]# ls /application/

mysql-5.6.35

4.??? 給mysql創建一個軟鏈接

[[email?protected] tools]# ln -s /application/mysql-5.6.35 /application/mysql

[[email?protected] tools]# ll /application/

total 8

lrwxrwxrwx? 1 root root?? 25 Mar? 8 23:41 mysql -> /application/mysql-5.6.35

drwxr-xr-x 13 root root 4096 Mar? 8 23:38 mysql-5.6.35

5.??? 賦予mysql安裝目錄中mysql軟件的所屬者

[[email?protected] application]# chown -R mysql.mysql /application/mysql/

[[email?protected] application]# ll mysql/

total 68

drwxr-xr-x? 2 mysql mysql? 4096 Mar? 8 23:38 bin

-rw-r--r--? 1 mysql mysql 17987 Nov 28 21:36 COPYING

drwxr-xr-x? 3 mysql mysql? 4096 Mar? 8 23:38 data

drwxr-xr-x? 2 mysql mysql? 4096 Mar? 8 23:38 docs

drwxr-xr-x? 3 mysql mysql? 4096 Mar? 8 23:38 include

drwxr-xr-x? 3 mysql mysql? 4096 Mar? 8 23:38 lib

drwxr-xr-x? 4 mysql mysql? 4096 Mar? 8 23:38 man

drwxr-xr-x 10 mysql mysql? 4096 Mar? 8 23:38 mysql-test

-rw-r--r--? 1 mysql mysql? 2496 Nov 28 21:36 README

drwxr-xr-x? 2 mysql mysql? 4096 Mar? 8 23:38 scripts

drwxr-xr-x 28 mysql mysql? 4096 Mar? 8 23:38 share

drwxr-xr-x? 4 mysql mysql? 4096 Mar? 8 23:38 sql-bench

drwxr-xr-x? 2 mysql mysql? 4096 Mar? 8 23:38 support-files

6.??? 初始化數據庫

[[email?protected] application]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

Installing MySQL system tables...2017-03-08 23:50:31 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

…………

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

7.??? 復制mysql安裝目錄下的腳本去linux系統服務并給執行權限

[[email?protected] application]# cp /application/mysql/support-files/mysql.server? /etc/init.d/mysqld

[[email?protected] application]# chmod +x /etc/init.d/mysqld

[[email?protected] application]# ll /etc/init.d/mysqld

-rwxr-xr-x 1 root root 10875 Mar? 8 23:51 /etc/init.d/mysqld

8.??? 替換配置文件

[[email?protected] application]# sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

9.??? 覆蓋原來的配置文件

[[email?protected] application]# \cp /application/mysql/support-files/my-default.cnf /etc/my.cnf

10.? 啟動mysql服務

[[email?protected] application]# /etc/init.d/mysqld start

Starting MySQL.Logging to ‘/application/mysql/data/localhost.err‘.

SUCCESS!

[[email?protected] application]# lsof -i:3306????????? #MySQL默認端口3306

COMMAND? PID? USER?? FD?? TYPE DEVICE SIZE/OFF NODE NAME

mysqld? 5189 mysql?? 10u? IPv6? 30071????? 0t0? TCP *:mysql (LISTEN)

11.? PATH路徑和開機自啟動

[[email?protected] application]# echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile

[[email?protected] application]# source /etc/profile

[[email?protected] application]# which mysql

/application/mysql/bin/mysql

[[email?protected] application]#??? chkconfig --add mysqld

[[email?protected] application]#??? chkconfig mysqld on

[[email?protected] application]# chkconfig --list|grep mysqld

mysqld??????? ??? ?0:off?? ?1:off?? ?2:on?? ?3:on?? ?4:on?? ?5:on?? ?6:off

12.? 給MySQL root用戶設置密碼

[[email?protected] application]# /application/mysql/bin/mysqladmin -u root password ‘oldboy123‘

Warning: Using a password on the command line interface can be insecure.???????? #這個只是一個警告,原因是在命令行輸入密碼!

測試是否能登陸

[[email?protected] application]# mysql -uroot -poldboy123

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.? Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> quit

Bye

到這一步mysql數據庫就安裝成功了!MySQL常用命令如下?? ↓

MySQL簡單常用命令

1.??? 查看所有數據庫:show databases;

2.??? 創建一個數據庫:create database oldboy;

3.??? 刪除一個數據庫(危險):drop database oldboy;

4.??? select user,host from mysql.user;

查詢選擇:select

user,host字段(列)

mysql數據庫的user表格

5.?? 退出MySQL:quit

6.?? 給用戶授權:grant all on wordpress.* to [email?protected]‘172.16.1.%‘ identified by ‘123456‘

總結

以上是生活随笔為你收集整理的mysql linux 安装部署,linux之MySQL安装部署(示例代码)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。