Sometimes we face issues with MySQL installation on a Linux system. If we simply remove MySQL packages and re-install doesn’t fix the issue, in that case, old settings may still exist on the server which again affects the new install. In that case, first, uninstall MySQL completely from the system and erase all settings of the old install. To do the same follow the below settings.
Advertisement
Note: Please do not use the below steps if MySQL has any running databases.
Step 1 – Uninstall MySQL Packages
First, uninstall all the MySQL packages installed on your server. Use one of the following commands as per your Linux distribution. The package names may vary based on the Operating system and installation types.
sudo yum remove mysql mysql-server #CentOS and RedHat systems sudo apt remove mysql mysql-server #Ubuntu and Debian systems sudo dnf remove mysql mysql-server #Fedora 22+ systemsStep 2 – Romove MySQL Directory
Now we need to remove MySQL data directory from system which by default exists at /var/lib/mysql. If you didn’t find this, It may be changed to some other place, which you can find in my.cnf file with variable datadir. Delete the /var/lib/mysql directory from the system but we prefer to rename it to keep a backup of existing files.
sudo mv /var/lib/mysql /var/lib/mysql_old_backup sudo mv /etc/mysql /etc/mysql_old_backupStep 3 – Reinstall MySQL (If Required)
After removing MySQL completely, install it again using package manager, It will recreate all the required directories on your system. Below are the commands to install MySQL from default package repositories.
sudo yum install mysql-server #CentOS and RedHat systems sudo apt install mysql-server #Ubuntu and Debian systems sudo dnf install mysql-server #Fedora 22+ systemsAfter completing the above steps, now you have a fresh MySQL install on your system with new settings.
Ive been struggling all day to try and get MySQL to work both from pacman and the download on their site so now i just want to remove all traces of it. As I believe the problem may lie in a broken previous installation. What is the best way to go about this? i have tried find -name mysql and deleted everything that came up but it still dosent work.
MySQL is an open-source relational database management system developed by Oracle based on structured query language (SQL). It is primarily written in C and C++ programming languages and licensed under the GNU Public License. The client-end API is used to query, filter, sort, group, and modify data stored in the database table in the form of rows and columns. This article is a step-by-step guide for installing and configuring MySQL server on an Arch-based Linux system.
Installation of MySQL on Manjaro
Follow the below steps to install the MySQL database.
Step 1: We will update and upgrade our system by executing the following command
$ sudo pacman -Syu
Step 2: Install MySQL from the official repository using pacman package manager
$ sudo pacman -S mysql
Step 3: Now, verify the installation by running the below command.
$ mysqld --version
Step 4: Start MySQL server by using the systemctl command.
$ sudo systemctl start mysqld $ sudo systemctl status mysqld
Step 5: Once again use systemctl command to enable MySQL service. After command execution, MySQL will restart whenever our machine boots up.
$ sudo systemctl enable mysqld
Configuring MySQL on Manjaro
Follow the below steps to configure MySQL on Manjaro.
Step 1: Start the MySQL configuration script as the sudo user. In this step, we’ll be prompted to change our MySQL installation’s security settings.
Install Apache,MariaDB, PHP (LAMP) di Manjaro Arch Linux
Install Apache,MariaDB, PHP (LAMP) di Manjaro Linux | Seperti yang kita ketahui bahwasahnya Apache, MariaDB,PHP adalah serangkaian komponen untuk membangun server di personal computer ataupun laptop kita.
Nantinya, server localhost ini bisa kita gunakan untuk membuat website yang tujuannya untuk uji coba.
Jika di Windows, XAMPP merupakan software yang paling banyak digunakan untuk membuat server localhost.
Untuk di linux, kita akan menggunakan terminal guna bisa menginstall LAMP.
LAMP adalah singkatan dari Linux, Apache, MySQL / MariaDB, PHP / Perl / Pyhton.
Pada kesempatan kali ini saya dari Bingungonline.com akan membagikan tutorial install Apache, MariaDB, PHP (LAMP) untuk Linux, Archlinux, manjaro, dan turunan lainnya.
Namun sebelumnya, buat kamu yang menyukai pembahasan-pembahasan seputar linux, kamu bisa membacanya di sini
Cara Install Apache,MariaDB, PHP (LAMP) di Manjaro Linux
1.Update Sistem
Jalankan perintah di bawah ini dengan akses root untuk mengupdate sistem linux kamu
sudo pacman -Syyu
Masukan password dan tekan enter
2. Install Apache
Setelah mengupdate sistem, sekarang silahkan install Apache Web Server dengan menggunakan perintah di bawah ini
sudo pacman -S apache
Edit /etc/httpd/conf/httpd.conf file,
Cari kode seperti di bawah ini, dan berikan komen (tanda # di awal) :
[...] # LoadModule unique_id_module modules/mod_unique_id.so [...]Simpan file dan keluar
Aktifkan apache
Untuk mengaktifkan apache di server kita, silahkan masukan perintah di bawah ini
sudo systemctl enable httpd sudo systemctl restart httpdUntuk memastikan apakah apache kita sudah aktif atau belum, errror atau tidak, jalankan perintah berikut :
sudo systemctl status httpdSample output:
httpd.service - Apache Web Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago Main PID: 1067 (httpd) Tasks: 82 (limit: 512) CGroup: /system.slice/httpd.service ├─1067 /usr/bin/httpd -k start -DFOREGROUND ├─1070 /usr/bin/httpd -k start -DFOREGROUND ├─1071 /usr/bin/httpd -k start -DFOREGROUND └─1072 /usr/bin/httpd -k start -DFOREGROUND Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.` Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably dete...ge Hint: Some lines were ellipsized, use -l to show in full. Apache server is ready to use.Jika pada terminal kamu muncul tampilan Active seperti di atas, artinya apache kita tidak memiliki error dan berjalan dengan baik
Test Apache
Mari kita buat contoh halaman sederhana untuk mengetest apache kita pada directory penyimpanan apache , i.e /srv/http.
sudo nano /srv/http/index.htmlTambahkan kode berikut:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Welcome</title> </head> <body> <h2>Welcome to my Web Server test page</h2> </body> </html>Jika sudah, silahkan buka browser kamu dan arahkan pada
sudo systemctl status httpd 6 or sudo systemctl status httpd 7.
Jika semuanya benar, maka akan tampil seperti pada gambar di bawah ini
3. Install MariaDB
Jalan perintah berikut untuk menginstall MariaDB
sudo pacman -S mysqlSeperti yang kita ketahui, MariaDB sekarang adalah default implementation dari MySQL di Arch Linux sejak 2013.
Jadi, kita akan mendapatkan beberapa pertanyaan untuk install MariaDB atau Percona server, cukup tekan sudo systemctl status httpd 8 dan tekan sudo systemctl status httpd 9 lalu tekan enter lagi.
[root@server ~]# pacman -S mysql :: There are 2 providers available for mysql: :: Repository extra 1) mariadb :: Repository community 2) percona-server Enter a number (default=1): `## Press Enter` resolving dependencies... looking for conflicting packages... Packages (7) boost-libs-1.60.0-2 icu-56.1-2 jemalloc-4.0.4-1libmariadbclient-10.1.11-1 libxml2-2.9.3-1 mariadb-clients-10.1.11-1 mariadb-10.1.11-1 Total Download Size: 30.68 MiB Total Installed Size: 218.10 MiB :: Proceed with installation? [Y/n]Kamu perlu menginstall MariaDB di directory, untuk melakukannya jalankan perintah berikut:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysqlUntuk mengaktifkan mysqld, jalankan perintah berikut :
[...] # LoadModule unique_id_module modules/mod_unique_id.so [...] 0Untuk memastikannya, sama seperti tadi. Silahkan cek dengan perintah berikut
[...] # LoadModule unique_id_module modules/mod_unique_id.so [...] 1Sample output:
[...] # LoadModule unique_id_module modules/mod_unique_id.so [...] 2Setup MySQL/MariaDB root user password
Kita harus mengatur passwod untuk akun root kita.
Untuk mengatur password, jalankan perintah berikut :
Sample output:
[...] # LoadModule unique_id_module modules/mod_unique_id.so [...] 44. Install PHP
Untuk menginstall PHP di Linux jalankan perintah berikut :
- Manjaro Arch Linux
- Ubuntu dan Debian
- Fedora
Setelah berhasil install PHP, kita perlu melakukan konfigurasi Apache PHP module.
Untuk melakukannya, edit httpd.service - Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor
preset: disabled)
Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago
Main PID: 1067 (httpd)
Tasks: 82 (limit: 512)
CGroup: /system.slice/httpd.service
├─1067 /usr/bin/httpd -k start -DFOREGROUND
├─1070 /usr/bin/httpd -k start -DFOREGROUND
├─1071 /usr/bin/httpd -k start -DFOREGROUND
└─1072 /usr/bin/httpd -k start -DFOREGROUND
Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.`
Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably
dete...ge
Hint: Some lines were ellipsized, use -l to show in full.
Apache server is ready to use.
0 file,
Cari baris berikut :
[...] # LoadModule unique_id_module modules/mod_unique_id.so [...] 9Uncomment baris tersebut sehingga menjadi seperti ini:
Then, add the following lines at the bottom:
sudo systemctl enable httpd sudo systemctl restart httpd 1Save and close the file.
Test PHP
Now create a httpd.service - Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor
preset: disabled)
Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago
Main PID: 1067 (httpd)
Tasks: 82 (limit: 512)
CGroup: /system.slice/httpd.service
├─1067 /usr/bin/httpd -k start -DFOREGROUND
├─1070 /usr/bin/httpd -k start -DFOREGROUND
├─1071 /usr/bin/httpd -k start -DFOREGROUND
└─1072 /usr/bin/httpd -k start -DFOREGROUND
Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.`
Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably
dete...ge
Hint: Some lines were ellipsized, use -l to show in full.
Apache server is ready to use.
1 file in the Apache root directory.
Add the following lines:
sudo systemctl enable httpd sudo systemctl restart httpd 3Restart httpd service.
sudo systemctl enable httpd sudo systemctl restart httpd 4Open up your web browser and navigate to httpd.service - Apache Web Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor
preset: disabled)
Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago
Main PID: 1067 (httpd)
Tasks: 82 (limit: 512)
CGroup: /system.slice/httpd.service
├─1067 /usr/bin/httpd -k start -DFOREGROUND
├─1070 /usr/bin/httpd -k start -DFOREGROUND
├─1071 /usr/bin/httpd -k start -DFOREGROUND
└─1072 /usr/bin/httpd -k start -DFOREGROUND
Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.`
Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably
dete...ge
Hint: Some lines were ellipsized, use -l to show in full.
Apache server is ready to use.
2. You should the screen like
below.
###5. Install phpMyAdmin
phpMyAdmin is a graphical MySQL/MariaDB administration tool that can be used to create, edit and delete databases.
To install it, run:
sudo systemctl enable httpd sudo systemctl restart httpd 5After installing, edit httpd.service - Apache Web Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago Main PID: 1067 (httpd) Tasks: 82 (limit: 512) CGroup: /system.slice/httpd.service ├─1067 /usr/bin/httpd -k start -DFOREGROUND ├─1070 /usr/bin/httpd -k start -DFOREGROUND ├─1071 /usr/bin/httpd -k start -DFOREGROUND └─1072 /usr/bin/httpd -k start -DFOREGROUND Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.` Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably dete...ge Hint: Some lines were ellipsized, use -l to show in full. Apache server is ready to use. 3 file,
sudo systemctl enable httpd sudo systemctl restart httpd 6Make sure the following lines are uncommented.
sudo systemctl enable httpd sudo systemctl restart httpd 7Save and close the file.
Next, create configuration file for phpMyAdmin,
sudo systemctl enable httpd sudo systemctl restart httpd 8Add the following lines:
sudo systemctl enable httpd sudo systemctl restart httpd 9Then, open Apache configuration file,
sudo nano /etc/httpd/conf/httpd.confAdd the following line at the end:
sudo systemctl status httpd 1Save and close the file.
Restart httpd service.
sudo systemctl status httpd 2Test phpMyAdmin
Open your browser and navigate to httpd.service - Apache Web Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2016-02-16 13:00:18 IST; 7s ago Main PID: 1067 (httpd) Tasks: 82 (limit: 512) CGroup: /system.slice/httpd.service ├─1067 /usr/bin/httpd -k start -DFOREGROUND ├─1070 /usr/bin/httpd -k start -DFOREGROUND ├─1071 /usr/bin/httpd -k start -DFOREGROUND └─1072 /usr/bin/httpd -k start -DFOREGROUND Feb 16 13:00:18 server systemd[1]: `Started Apache Web Server.` Feb 16 13:00:18 server httpd[1067]: AH00558: httpd: Could not reliably dete...ge Hint: Some lines were ellipsized, use -l to show in full. Apache server is ready to use. 4.
Enter the MySQL/MariaDB root username and it’s password.
Here it is how my phpMyAdmin web console looks like.
You might see an error that says “The configuration file now needs a secret passphrase (blowfish_secret)” at the bottom of phpMyAdmin dashboard.
To get rid of this error, edit /etc/webapps/phpmyadmin/config.inc.php file,
sudo systemctl status httpd 3Find the following line and specify bluefish secret passphrase:
sudo systemctl status httpd 4Save and close the file. Restart Apache service.
sudo systemctl status httpd 2The error will be gone now.
That’s all for now. At this stage, you have a working LAMP stack, and is ready to host your websites.