RSS

Mengatasi error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Cara mengatasi error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 


1. buka configurasi my.cnf, edit seperti dibawah ini kemudian simpan!
 
    # The following options will be passed to all MySQL clients
    [client]
    #socket      = /tmp/mysql.sock
    socket        = /var/run/mysqld/mysqld.sock

    # Here follows entries for some specific programs

    # The MySQL server
    [mysqld]
    #socket      = /tmp/mysql.sock
    socket        = /var/run/mysqld/mysqld.sock

2. Buat folder mysqld/  di direktori /var/run/ :

    sudo mkdir -p /var/run/mysqld/

3. Then create a mysqld.pid file with touch:

    sudo touch /var/run/mysqld/mysqld.pid

4. Next create a mysqld.sock file with touch:

    sudo touch /var/run/mysqld/mysqld.sock

5. Now change the ownerships of the directory and files to mysql:mysql like this:

    sudo chown mysql:mysql -R /var/run/mysqld

6. And restart MySQL like this to get those files set and created:

    sudo service mysql restart





  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Install mysql 5.1 on ubuntu 23.10 server

#!/bin/bash
# Run as root

set -e

apt-get update
apt-get install -y build-essential
apt-get install -y libncurses5-dev
useradd mysql

cd
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz
tar xzvf mysql-5.1.73.tar.gz
cd mysql-5.1.73

./configure \
'--prefix=/usr' \
'--exec-prefix=/usr' \
'--libexecdir=/usr/sbin' \
'--datadir=/usr/share' \
'--localstatedir=/var/lib/mysql' \
'--includedir=/usr/include' \
'--infodir=/usr/share/info' \
'--mandir=/usr/share/man' \
'--with-system-type=debian-linux-gnu' \
'--enable-shared' \
'--enable-static' \
'--enable-thread-safe-client' \
'--enable-assembler' \
'--enable-local-infile' \
'--with-fast-mutexes' \
'--with-big-tables' \
'--with-unix-socket-path=/var/run/mysqld/mysqld.sock' \
'--with-mysqld-user=mysql' \
'--with-libwrap' \
'--with-readline' \
'--with-ssl' \
'--without-docs' \
'--with-extra-charsets=all' \
'--with-plugins=max' \
'--with-embedded-server' \
'--with-embedded-privilege-control' \
CXXFLAGS="-Wno-narrowing -fpermissive"

make
make install

mkdir -p /etc/mysql
mkdir -p /var/lib/mysql
mkdir -p /etc/mysql/conf.d
echo -e '[mysqld_safe]\nsyslog' > /etc/mysql/conf.d/mysqld_safe_syslog.cnf
cp /usr/share/mysql/my-medium.cnf /etc/mysql/my.cnf
sed -i 's#.*datadir.*#datadir = /var/lib/mysql#g' /etc/mysql/my.cnf
chown mysql:mysql -R /var/lib/mysql

mysql_install_db --user=mysql
mysqld_safe -user=mysql &
/usr/bin/mysql_secure_installation

cp /usr/share/mysql/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
update-rc.d mysql defaults

Reff: https://gist.github.com/huangqiheng/7fbfcd7f4f97255447713ec6e9e85257
jika hasil restore dari mysql 5.5 ke mysql 5.1 gagal, tambahkan script ini di my.cnf 
log_bin_trust_function_creators = 1
restart mysql => sudo /etc/init.d/mysql restart 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Install Mysql 8 Ubuntu 23

sudo apt install mysql-server

sudo systemctl start mysql
sudo systemctl status mysql


sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password12345';

mysql_secure_installation
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address            = 127.0.0.1 => rubah ke IP server mysql

sudo systemctl restart mysql

#Login to MySQL console using root
mysql -u root -p

#In the MySQL console, we will create a new user called dhani with password password123
CREATE USER 'dhani'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password123';

#Optionally, we can also grant this new user to access all the databases
GRANT ALL PRIVILEGES ON *.* TO 'dhani'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

#Log in to MySQL Console as root
mysql -u root -p

#Create a new user
CREATE USER 'dhani'@'%' IDENTIFIED WITH mysql_native_password BY 'password123';
GRANT ALL PRIVILEGES ON *.* TO 'dhani'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Set IP Address Ubuntu 23

Install Net-Tools
apt install net-tools

Masuk ke direktory netplan
root@server:/# cd /etc/netplan/
root@server:/etc/netplan#
pico 50-cloud-init.yaml

#network:
#    ethernets:
#        eno1:
#            dhcp4: true
#    version: 2

# create new
network:
  ethernets:
    # interface name
    enp1s0:
      dhcp4: false
      # IP address/subnet mask
      addresses: [10.0.0.30/24]
      # default gateway
      # [metric] : set priority (specify it if multiple NICs are set)
      # lower value is higher priority
      routes:
        - to: default
          via: 10.0.0.1
          metric: 100
      nameservers:
        # name server to bind
        addresses: [10.0.0.10,10.0.0.11]
        # DNS search base
        search: [srv.world,server.education]
      dhcp6: false
  version: 2

# apply changes
root@localhost:~# netplan apply

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS