阿里云服务器的web项目发布之路:(四)云服务器mysql数据库的安装

版权声明:如有转载请注明出处 https://blog.csdn.net/hdp134793/article/details/83573365

阿里云服务器安装mysql的详情步骤
1-1.通过登录服务器,执行yum命令来实现相关的操作,语句如下所示:
安装mysql:
第一步:下载rpm包
[root@hdp ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing… ################################# [100%]
Updating / installing…
第二步:安装mysql服务
[root@hdp ~]# 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命令:
[root@hdp~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
查看mysql启动状态命令:(判断是否成功启动)
[root@izwz ~]# 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:之后)的话这样执行。
[root@hdp ~]# 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…
    [root@hdp ~]#
    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文件中的默认密码。

下一篇:nodejs在云服务器上安装和部署

码字不易,喜欢的话关注下或者给点赞赏吧!

皮一下很开心,这个zfb二维码是认真的,实在土豪可以扫一扫扶贫,>=10元的将将代写表白情诗一首(支付宝加好友([email protected])私发对象名字)
在这里插入图片描述

扶贫1元(备注城市)即上榜,看看有多少人

全网感谢:
http://www.bcodelove.top:8080/bcode/jsp/apphome/rewardlist/rewardlist.html

猜你喜欢

转载自blog.csdn.net/hdp134793/article/details/83573365