1. 程式人生 > >阿里雲伺服器的web專案釋出之路:(四)雲伺服器mysql資料庫的安裝

阿里雲伺服器的web專案釋出之路:(四)雲伺服器mysql資料庫的安裝

阿里雲伺服器安裝mysql的詳情步驟 1-1.通過登入伺服器,執行yum命令來實現相關的操作,語句如下所示: 安裝mysql: 第一步:下載rpm包 [[email protected] ~]# Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm Preparing… ################################# [100%] Updating / installing… 第二步:安裝mysql服務 [[email protected]

~]# yum -y install mysql-community-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies –> Running transaction check —> Package mysql-community-server.x86_64 0:5.6.38-2.el7 will be installed –> Processing Dependency: mysql-community-common(x86-64) = 5.6.38-2.el7 for package: mysql-community-server-5.6.38-2.el7.x86_64 …(此處省略n行) …(此處省略n行) Replaced: mariadb.x86_64 1:5.5.56-2.el7 mariadb-devel.x86_64 1:5.5.56-2.el7 mariadb-libs.x86_64 1:5.5.56-2.el7 Complete! 到了這裡就已經把mysql安裝上去了。 第三步:啟動mysql並檢視其狀態
啟動mysql命令: [[email protected]~]# service mysqld start Redirecting to /bin/systemctl start mysqld.service 檢視mysql啟動狀態命令:(判斷是否成功啟動) [[email protected] ~]# service mysqld status Redirecting to /bin/systemctl status mysqld.service ● mysqld.service - MySQL Community Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running)
since Thu 2017-11-02 18:53:14 CST; 11min ago Main PID: 13242 (mysqld_safe) CGroup: /system.slice/mysqld.service … 第四步:配置mysql的密碼(這個地方就會存在一個問題,如果在配置檔案中沒有找到預設的初始化密碼的時候,那麼就應該去修改內部的配置檔案,讓其免密碼登入,免密碼登進去了之後然後再設定密碼,後面再重新改回來) A.先假設你已經設定或者拿到了mysql的初始密碼(一般是mysqld.log檔案中的localhost:之後)的話這樣執行。 [[email protected] ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we’ll need the current password for the root user. If you’ve just installed MySQL, and you haven’t set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): #[輸入你設定的密碼] OK, successfully used password, moving on… Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y #[設定root使用者密碼] New password: Re-enter new password: Password updated successfully! Reloading privilege tables… … Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y #[刪除匿名使用者] … Success! Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n #[禁止root遠端登入] … skipping. By default, MySQL comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y #[刪除test資料庫]

  • Dropping test database… ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist … Failed! Not critical, keep moving…
  • Removing privileges on test database… … Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y #[重新整理許可權] … Success! All done! If you’ve completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up… [[email protected] ~]# B.要是你的mysql密碼沒有設定的話可以這樣去設定(直接敲mysql去檢驗有沒有密碼能進去,出現mysql>的話說明設定了) B-1先關閉mysql服務:systemctl stop mysqld.service B-2然後修改配置檔案:vi /etc/my.cnf 進到這個檔案之後輸入i命令進入編輯模式,修改後esc退出編輯模式,執行:wq儲存修改並退出命令即可。 B-3其次修改my.cof,在其檔案的最後一行新增一句話:skip-grant-tables,主要是為了免密碼登入. B-4 啟動mysql服務:systemctl start mysqld.service B-5 root登入mysql:mysql -u root B-6 修改mysql登入密碼: mysql>use mysql ; mysql>update mysql.user set authentication_string=password(‘123456’) where user=‘root’ ; 執行這兩句話的話就可以將密碼改成123456這個根據個人情況修改。 B-7重新執行B-2操作,將檔案中的最後一行還原(原先加的刪除掉)。 然後重新啟動的話你的mysql就有你自己設定的密碼了。否則的話你可以去用mysqld.log檔案中的預設密碼。

碼字不易,喜歡的話關注下或者給點讚賞吧!

皮一下很開心,這個zfb二維碼是認真的,實在土豪可以掃一掃扶貧,>=10元的將將代寫表白情詩一首(支付寶加好友私發物件名字) 在這裡插入圖片描述

扶貧1元即上榜,看看有多少人