본문 바로가기
일상생활

Amazon EC2 nodejs mysql 설치

by WebHack 2023. 3. 10.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
. ~/.nvm/nvm.sh
nvm --version
nvm install node
node --version

node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)

위와 같은 에러 발생시 node 버전 다운
nvm ls-remote
nvm install 16.19.1
node --version
nvm ls

ln -s /root/.nvm/versions/node/v16.19.1/bin/node /usr/bin/node
ln -s /root/.nvm/versions/node/v16.19.1/bin/rpm /usr/bin/npm
ln -s /root/.nvm/versions/node/v16.19.1/bin/npx /usr/bin/npx

ln -s /root/.nvm/versions/node/v16.19.1/lib/node /usr/lib/node

mkdir /usr/local/nodeJsApps
chown ec2-user:ec2-user /usr/local/nodeJsApps

#제거는 nvm uninstall
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
yum --enablerepo=mysql80-community install mysql-community-server
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum --enablerepo=mysql80-community install mysql-community-server
mysql -V
systemctl start mysqld
systemctl status mysqld
netstat -nltp

#mysql_secure_installation
#임시 비번 확인
cat /var/log/mysqld.log | grep password

 


ㅇ mysql 비밀번호 변경 방법

mysql -u root -p
use mysql;
select host, user from user;
ALTER USER 'root'@'localhost' IDENTIFIED BY '{PASSWORD}';
#CREATE USER 'root'@'%' IDENTIFIED BY '{PASSWORD}';
#ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '{PASSWORD}';
CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '{PASSWORD}';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;
quit

 

ㅇ 밑에 내용은 기존 패스워드를 무시를 하고 하는 방법인데 에러남

systemctl stop mysqld
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
systemctl start mysqld
mysql -u root
use mysql;
select * from user;
ALTER USER 'root'@'localhost' IDENTIFIED BY '{PASSWORD}';
FLUSH PRIVILEGES;
quit
systemctl stop mysqld
systemctl unset-environment MYSQLD_OPTS
systemctl start mysqld