mysql root用户改密码。基于LNMP架构搭建网站。

打印 上一主题 下一主题

主题 562|帖子 562|积分 1686

假如MySQL root用户密码忘记,可以通过修改配置文件来登录MySQL,修改密码。

修改配置文件,在 /etc/my.cnf 中,




 生存并退出,重启MySQL,

  1. systemctl restart mysql
  2. d
复制代码

此时进入MySQL,就已经不须要密码了,直接输入MySQL就会进入。

  1. mysql
复制代码

更改密码

  1. update mysql
  2. .user set authentication_string=password('123456') where user'root' and host'localhost';
复制代码

革新权限

  1. flush privileges;
复制代码

修改完之后要及时删除配置项

  1. vim /etc/my.cnf
复制代码

 更改完文件之后,要重启MySQL。


此时用新密码登录MySQL root用户。

  1. mysql
  2. -uroot -p123456
复制代码


yum 安装nginx
 


  1. yum install nginx
复制代码

启动nginx


  1. nginx
复制代码
 用命令查看80端口

  1. ss -nplt | grep 80
复制代码
发现nginx
已经启动。



摆设php 

进入rpm软件包仓库网站。

https://rpms.remirepo.net/ 是一个 RPM 软件包仓库,它提供大量的 PHP 和相干扩展包

Remi's RPM repository (remirepo.net)
https://rpms.remirepo.net/

右键-复制链接。


 在终端中用yum举行下载。


 

  1. yum -y install php74-php-fpm
复制代码
  1. yum -y install php74-php-xsl php74-php php74-php-cli php74-php-devel php74-php-gd php74-php-pdo php74-php-mysql
  2. php74-php-fpm
复制代码
 


 启动php

  1. systemctl restart php74-php-fpm
复制代码

查抄是否启动乐成

  1. ss -nplt | grep 9000
复制代码

nginx
关联php


将nginx
文件备份,文件在 /etc/nginx
/nginx
.conf。


  1. cp /etc/nginx
  2. /nginx
  3. .conf /etc/nginx
  4. /nginx
  5. .conf.bak
复制代码

对nginx
配置文件举行编辑


  1. vim /etc/nginx
  2. /nginx
  3. .conf
复制代码
 可以用 加个+42来指定文件开启时光标在第42行。

  1. vim +42 /etc/nginx
  2. /nginx
  3. .conf
复制代码



在第42行下举行编辑,添加以下代码

  1. index index.php index.html index.htm;          location ~ \.php$         {                  include fastcgi_params;                  fastcgi_pass 127.0.0.1:9000;                  fastcgi_index index.php;                  fastcgi_param SCRIPT_FILENAME /usr/share/nginx
  2. /html/$fastcgi_script_name;          }
复制代码

可以用nginx
-t 来检测是否有语法问题


  1. nginx
  2. -t
复制代码

配置文件语法没有问题后,重启nginx


  1. nginx
  2. -s reload
复制代码

编写一个探测文件来查看nginx
和php是否毗连乐成


  1. vim index.php
复制代码
  1. <?php
  2. phpinfo();
  3. ?>
复制代码

 用欣赏器访问ip地址,显示下面界面,就体现毗连乐成。


接下来就是让项目上线

将压缩包从本地上传到虚拟机中。解压

  1. tar -zxvf wordpress-6.2.2-zh_CN.tar.gz
复制代码

 将解压后的目录下的文件和目录拷贝到 /usr/share/nginx
/html/ 目录下


  1. cp -r /root/wordpress/* /usr/share/nginx
  2. /html/
复制代码
 删除之前的测试文件index.php。

  1. rm -rf index.php
复制代码


进入mysql
中创建数据库


  1. create database wordpress;
复制代码

打开欣赏器访问ip地址。



 这里输入刚刚创建的数据库名wordpress,用户名root 。


点击提交后,看到无法写入wp-config.php文件,须要我们手动创建并配置。


须要创建在 /usr/share/nginx
/html 目录下,


  1. vim wp-config.php
复制代码
将以下代码添加到文件中。

  1. <?php
  2. /**
  3. * The base configuration for WordPress
  4. *
  5. * The wp-config.php creation script uses this file during the installation.
  6. * You don't have to use the web site, you can copy this file to "wp-config.php"
  7. * and fill in the values.
  8. *
  9. * This file contains the following configurations:
  10. *
  11. * * Database settings
  12. * * Secret keys
  13. * * Database table prefix
  14. * * ABSPATH
  15. *
  16. * @link https://wordpress.org/documentation/article/editing-wp-config-php/
  17. *
  18. * @package WordPress
  19. */
  20. // ** Database settings - You can get this info from your web host ** //
  21. /** The name of the database for WordPress */
  22. define( 'DB_NAME', 'wordpress' );
  23. /** Database username */
  24. define( 'DB_USER', 'root' );
  25. /** Database password */
  26. define( 'DB_PASSWORD', '123' );
  27. /** Database hostname */
  28. define( 'DB_HOST', 'localhost' );
  29. /** Database charset to use in creating database tables. */
  30. define( 'DB_CHARSET', 'utf8mb4' );
  31. /** The database collate type. Don't change this if in doubt. */
  32. define( 'DB_COLLATE', '' );
  33. /**#@+
  34. * Authentication unique keys and salts.
  35. *
  36. * Change these to different unique phrases! You can generate these using
  37. * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
  38. *
  39. * You can change these at any point in time to invalidate all existing cookies.
  40. * This will force all users to have to log in again.
  41. *
  42. * @since 2.6.0
  43. */
  44. define( 'AUTH_KEY',         '^ES>dqfaA%hn5{P[VB!I d3 gezm;J`agkJ~m<E58/*a<(q:D, O)7rIjQGkd|1@' );
  45. define( 'SECURE_AUTH_KEY',  'kqD}9<+<?Mc3d+4N+v71Zq+OS=|m-@l(J|lSMKi_x5+Wi-!b|uvDs%qT!`MDJ[*=' );
  46. define( 'LOGGED_IN_KEY',    'I.$A3BAHf<grZ.;q3]c+D{3%cS#&L!SDo%NIi_PXjvq3Bivt*Ue+h&TX-{Wj9%}?' );
  47. define( 'NONCE_KEY',        'rJW2hf(L|8T(!.ek^GFLCDr0.#K3_mYnP3HO@:s6Q(%:tAUwYCE_[~M%f$)?[Ck%' );
  48. define( 'AUTH_SALT',        'wH/OAd`MEb9[gzu3PT_tVv3m/I%p*@eo*CVe`^KyH5_:{`WdN2%Z-xns0.E_+W#g' );
  49. define( 'SECURE_AUTH_SALT', 'q~ej>{5{%3(59J&hOP;Z{Gn-NLbsIaLvZRniA=jkhCNj/&|3ssR*(r%R,xq==1NW' );
  50. define( 'LOGGED_IN_SALT',   '<t*,_SprcP>6EG=wSXIFm]93SK$A8Vc-B0E>*d2lg[<CE#X}{m:nvtE4%5c#kip]' );
  51. define( 'NONCE_SALT',       'QP9To>rx:oA,X5D%2cV^Ni,Zr7S_BwUdAvEj)@scV-To9Hv%?U$O=v*]1Z[+|Sr!' );
  52. /**#@-*/
  53. /**
  54. * WordPress database table prefix.
  55. *
  56. * You can have multiple installations in one database if you give each
  57. * a unique prefix. Only numbers, letters, and underscores please!
  58. */
  59. $table_prefix = 'wp_';
  60. /**
  61. * For developers: WordPress debugging mode.
  62. *
  63. * Change this to true to enable the display of notices during development.
  64. * It is strongly recommended that plugin and theme developers use WP_DEBUG
  65. * in their development environments.
  66. *
  67. * For information on other constants that can be used for debugging,
  68. * visit the documentation.
  69. *
  70. * @link https://wordpress.org/documentation/article/debugging-in-wordpress/
  71. */
  72. define( 'WP_DEBUG', false );
  73. /* Add any custom values between this line and the "stop editing" line. */
  74. /* That's all, stop editing! Happy publishing. */
  75. /** Absolute path to the WordPress directory. */
  76. if ( ! defined( 'ABSPATH' ) ) {
  77.         define( 'ABSPATH', __DIR__ . '/' );
  78. }
  79. /** Sets up WordPress vars and included files. */
  80. require_once ABSPATH . 'wp-settings.php';
复制代码

 然后点击运行安装程序。会进入这个界面。填入信息。



 点击安装WordPress。安装乐成。点击登录。



 输入用户名和密码,登录。


 显示这个界面,乐成了。










免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

去皮卡多

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表