[root@VM-0-2-centos ~]# vim .bash_profile# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
~
".bash_profile" 12L, 176C
打开 .bashrc 文件显示如下,表示 nvm 指令写入到 .bashrc 文件中了
[root@VM-0-2-centos ~]# vim .bashrc# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
".bashrc" 16L, 373C
可以使用如下命令将环境变量生效,然后就可以使用 nvm 指令
[root@VM-0-2-centos ~]# source .bashrc
验证 nvm 指令,显示版本号表示成功
[root@VM-0-2-centos ~]# nvm -v
0.38.0
2、yum 介绍
yum 是 CentOS 自带的软件,主要用来管理 CentOS 的软件仓库
yum -y 表示选择同意
[root@VM-0-2-centos ~]# yum -y
四、CentOS Node.js环境搭建
安装最新的 node 版本
[root@VM-0-2-centos ~]# nvm install node
Downloading and installing node v16.7.0...
Downloading https://nodejs.org/dist/v16.7.0/node-v16.7.0-linux-x64.tar.xz...
################################################################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.7.0 (npm v7.20.3)
Creating default alias: default -> node (-> v16.7.0)
[root@VM-0-2-centos ~]#
[root@VM-0-2-centos nginx-1.12.2]# cd src/os/unix
[root@VM-0-2-centos unix]# vi ngx_user.c
将如下代码注释掉,保存退出
#ifdef __GLIBC__
/* work around the glibc bug */
/* cd.current_salt[0] = ~salt[0]; */
#endif
重新进入 nginx 源码目录下,重新编译
[root@VM-0-2-centos unix]# vi ngx_user.c
[root@VM-0-2-centos unix]# cd ..
[root@VM-0-2-centos os]# cd /root
[root@VM-0-2-centos ~]# cd nginx/
[root@VM-0-2-centos nginx]# ls
nginx-1.12.2 nginx-1.12.2.tar.gz
[root@VM-0-2-centos nginx]# cd nginx-1.12.2/
[root@VM-0-2-centos nginx-1.12.2]# make -j4
[root@VM-0-2-centos front-resources]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@VM-0-2-centos front-resources]#
在查看文件内容时如果想显示行号,可以按下 shift + 冒号键,然后输入: set nu 即可显示行号
// 注意:我们要安装的是 MySQL 服务端
// 如果输入的是 mysql,则只会安装客户端
yum install mysql-server
安装完成后,输入 mysql -u root -p 显示 MySQL 没有启动
完毕!
[root@VM-0-2-centos ~]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@VM-0-2-centos ~]#
检查 MySQL 状态
[root@VM-0-2-centos ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
Active: inactive (dead)
启动 MySQL
[root@VM-0-2-centos ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@VM-0-2-centos ~]#
不用输入密码直接回车就可以登录
[root@VM-0-2-centos ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, 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>
如果 MySQL 在初始化的时候给了默认密码,可以到 log 日志中去找
cat /var/log/mysqld.log |grep password
复制默认密码后,重新登录
mysql -u root -p
查看数据库,如果显示:You must reset your password using ALTER USER …
show databases;
那就重置密码:密码必须有字母、数字、字符
所设置的真正密码同服务器密码
alter user 'root'@'localhost' identified by '示例:lgk123123.';
再重新使用设置的密码登录
查看数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
新建数据库:book 是数据库名
create database book;
删除数据库
drop database db_name;
使用数据库
use book;
查看数据库表
show tables;
创建数据库表:test
CREATE TABLE tb_test(
id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(60) NOT NULL,
score TINYINT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY(id)
)ENGINE=InnoDB;
删除表
DROP TABLE IF EXISTS tb_name;
在使用 Navicat 连接测试数据库时,可能会报错:Test Failed 1130 - Host ‘服务器IP’ is not allowed to connect to this MySQL server
可以使用命令行的方式(登录状态)输入下列命令
// 使用数据库
use mysql;
// % 是通配符,表示匹配所有IP
// 使用 mysql_native_password 插件进行验证(与 v8.0 之前的不同了)
// 密码可以使用原来的,也可以设置简单的 123456
create user 'root'@'%' identified with mysql_native_password by '123456';
// 赋予所有权限给 'root'@'%'
grant all privileges on *.* to 'root'@'%';
// 使设置生效
flush privileges;
芝加哥位于美国伊利诺伊州的东北部,是美国重要的城市之一。对于身处这座城市的人们,了解芝加哥时区无疑是日常生活中的一部分。我自己在这里生活的时候,时区的变化让我对时间更加敏感。芝加哥时区,其实就是中部标准时间(Central Standard Time,CST), UTC-6。这种时间定义不仅影响着我...