MySQL: Package 'mysql-server' has no installation candidate - mysql

This error is being shown whenever I want to install any software via command line.
Even if i try to install softwares which I know are present at the source from where I am downloading.
Below is the full error message i am getting :
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mysql-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'mysql-server' has no installation candidate

It worked for me.
If you have followed all the previous steps successfully and after running sudo apt-get install mysql-server you are getting an error then try this
sudo apt-get install mariadb-server

I experienced this issue when trying to install MySQL Server on Debian 10.
Here's how I fixed it:
The issue is caused by the MySQL server apt repository not being included in your system's software repository list. In Debian 10 for example, MariaDB, a community fork of the MySQL project, is packaged as the default MySQL variant.
So to fix this first, add the MySQL server apt repository to your system's software repository list. Follow these steps:
Go to the download page for the MySQL APT repository at:
https://dev.mysql.com/downloads/repo/apt/
Select and download the release package for your Linux distribution. You can use:
sudo wget https://the-download-link
In my case it was:
sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
Install the downloaded release package with the following command, replacing version-specific-package-name with the name of the downloaded package (preceded by its path, if you are not running the command inside the folder where the package is):
sudo dpkg -i version-specific-package-name.deb
In my case it was:
sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
Note: dpkg is used to install, remove, and inspect .deb software packages. The -i flag indicates that we’d like to install from the specified file.
During the installation, you’ll be presented with a configuration screen where you can specify which version of MySQL you’d prefer, along with an option to install repositories for other MySQL-related tools. The defaults will add the repository information for the latest stable version of MySQL and nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.
You'll also be asked to select a repository to add. Choose 'debian buster' which has the package 'mysql-server' in it. After the adding this repository you can update the repository and use the below command to install MySQL.
sudo apt-get install mysql-server
The package will now finish adding the repository. Refresh your apt package cache to make the new software packages available:
sudo apt update
Note: If you ever need to update the configuration of these repositories, just run sudo dpkg-reconfigure mysql-apt-config, select new options, and then sudo apt-get update to refresh your package cache.
Install MySQL by the following command:
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
Note: This installs the package for the MySQL server, as well as the packages for the client and for the database common files. During the installation, you are asked to supply a password for the root user for your MySQL installation.
The MySQL server is started automatically after installation. You can check the status of the MySQLserver with the following command:
sudo service mysql status
Stop the MySQL server with the following command:
sudo service mysql stop
To restart the MySQL server, use the following command:
sudo service mysql start
MySQL creates a default user called root. You can change the password to any password of your choice by logging in to MySQL console using socket authentication:
sudo mysql -u root
Then run the command below to change the password
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'your-preferred-password';
Reference:
A Quick Guide to Using the MySQL APT Repository
How To Install the Latest MySQL on Debian 10
That's all.
I hope this helps

You can install mysql by
sudo apt install default-mysql-server
--------
sudo service mysql status
● mariadb.service - MariaDB 10.3.31 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-02-09 13:19:33 +08; 33s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 18537 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 4915)
Memory: 73.1M
CGroup: /system.slice/mariadb.service
└─18537 /usr/sbin/mysqld

run:
apt install default-mysql-server
which installs MariaDB unfortunately, but still responds to service mysql status

Most likely you are running on ubuntu. It is important to run apt-get update first.

Related

When Ubuntu 18.04 deploys zabbix4.0, the database type is PostgreSQL instead of MySQL. How can I set this to support MySQL?

In Ubuntu 18.04 server, I use binary file to install zabbix4.0 according to the official website document of zabbix4.0, and I use MySQL 5.7.30 database. After installation, when I configure the front end of zabbix4.0,In the database configuration page, I only see one option of PostgreSQL, not mysql, as shown in the following figure:
In my server, I have installed MySQL version 5.7.30, and imported the data of ZABBIX 4.0 into the ZABBIX database, without any PostgreSQL installed
Excuse me, how can I make zabbix4.0 support MySQL 5.7.30 that I have installed? Thank you!
I installed zabbix4.0 according to the official documents:
https://www.zabbix.com/documentation/4.0/zh/manual/installation/install_from_packages/debian_ubuntu
This is my installation method:
# install zabbix
cd ~/download
wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-
release/zabbix-release_ 4.0-2+bionic_ all.deb
sudo dpkg -i zabbix-release_ 4.0-2+bionic_ all.deb
sudo apt-get update
#install Server/proxy/
sudo apt-get install -y zabbix-server-mysql
sudo apt-get install -y zabbix-frontend-php
With Ubuntu, you got two type of databases when donwloading Zabbix, PostgreSql and MySql. You need to re-download (I mean installation and configuration) Zabbix choosing MySql as database.
The following link could help Zabbix (Ubuntu) with MySql as database
The current version of the package is 4.0-3, so instead, you must do this :
Install repository
# wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb
# sudo dpkg -i zabbix-release_4.0-3+bionic_all.deb
# sudo apt update
Install server, frontend, agent
# sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Unatttended MySQL 8 community install on Ubuntu 18.04 WSL

I am trying to install MySQL 8 on an Ubuntu (that is a Windows Subsystem for Linux) without any prompts.
I have the following script:
apt-key add --keyserver pgp.mit.edu --recv-keys 5072E1F5
echo 'deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0' > /etc/apt/sources.list.d/mysql.list
apt-get update --yes
apt-get install --yes debconf-utils
echo 'mysql-community-server mysql-community-server/root-pass password' | sudo debconf-set-selections
echo 'mysql-community-server mysql-community-server/re-root-pass password' | sudo debconf-set-selections
apt-get install --yes mysql-community-server
(partly constructed thanks to the answers in this question)
and it appears to work fine, except that it prompts me to select authentication method... I want to pick the mysql_native_password and do so without being prompted interactively.
I'm guessing the solution is another debconf-set-selections setting, but... In addition to asking what is it for this case... Is there a reference of all possible options somewhere?
There's also the issue that apt-get says that a symlink is created for the service, and yet the service isn't created... But that's not really a showstopper, as I'm using WSL merely as a test ground for an actual Ubuntu server, where I'd think this would work... hopefully.
EDIT1: Nevermind the original question... I managed to find an answer here
which led to stumble upon this dockerfile
So I ended up adding
echo 'mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)' | sudo debconf-set-selections
is the line I need...
HOWEVER, the other, possibly WSL specific issue remains... that is, no MySQL service is created. I should note that while I have MySQL outside of WSL, the server is turned off, specifically so that the WSL could run.
I get the following output upon the install, near the end:
Setting up mysql-community-server (8.0.16-2ubuntu18.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
mysql-community-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
And the only thing I can find related to that is suggestions of complete reinstall, but even reinstalling the WSL instance doesn't fix this.
EDIT2: Adding
apt-get dist-upgrade --yes --allow-remove-essential --allow-change-held-packages
Fixes the above error, and yet despite there not being any errors, the service is still not created.
I sort of fixed the missing mysql service by copying the /etc/init.d/mysql file from another WSL instance (mysql 8 installed through an upgrade) to /etc/init.d
sudo service mysql start
returns a [fail], but the mysql daemon runs just fine.
Otherwise, I've seen people achieve this more cleanly by installing a lower version from MySQL's repo first, and then upgrade to mysql 8.

How to install mysql-server in Ubuntu

I have mariadb in my ubuntu system but it is not working properly , so i want to again install mysql in my system .
For Remove mariadb i have run these commands .
sudo apt-get --purge remove "mysql*"
sudo mv /etc/mysql/ /tmp/mysql_configs/
nano /etc/apt/sources.list
sudo apt-get update
sudo apt-get install mysql-server-5.6
but after step 5 it's give me these errors :
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
libmysqlclient18 : Depends: mysql-common (= 5.6.30-1ubuntu14.04)
mariadb-server-5.5 : Breaks: mysql-server-5.6
Breaks: virtual-mysql-server
mariadb-server-core-5.5 : Conflicts: mysql-server-5.6
mysql-server-5.6 : Depends: mysql-client-5.6 (>= 5.6.30-0ubuntu0.14.04.1)
Depends: mysql-server-core-5.6 (= 5.6.30-0ubuntu0.14.04.1)
Recommends: mysql-common-5.6 but it is not going to be installed
Breaks: virtual-mysql-server
W: Duplicate sources.list entry http://debian.datastax.com/community/ stable/main amd64 Packages (/var/lib/apt/lists/debian.datastax.com_community_dists_stable_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://debian.datastax.com/community/ stable/main i386 Packages (/var/lib/apt/lists/debian.datastax.com_community_dists_stable_main_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Can anyone give me suggestion how can i install mysql in my system . Thanks in advance .
First of all, you need to update the system.
sudo apt update && upgrade
then perform the MySQL installation commands and follow the instructions.
sudo apt install mysql-server
sudo mysql_secure_installation
Once it has done. try to open MySQL.
sudo mysql
try to check the authentication method each of your MySQL user accounts uses with the following command in the MySQL terminal:
SELECT user,authentication_string,plugin,host FROM mysql.user;
this will return users with authentication_string.
Change the MySQL root password with the following command.
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
Flush Privileges which tells the server to reload the grant tables and put your new changes into effect
It's very simple to install mysql on ubuntu , just follow these steps :
Step 1 : update the system
sudo apt update
Step 2 : Install mysql package
sudo apt install mysql-server
Step 3 : Once the installation is completed, the MySQL service will start automatically. To check whether the MySQL server is running, type:
sudo systemctl status mysql
The output of the following command should be :
OUTPUT
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-06-20 11:30:23 PDT; 5min ago
Main PID: 17382 (mysqld)
Tasks: 27 (limit: 2321)
CGroup: /system.slice/mysql.service
`-17382 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Step 4 : Securing MySQL
sudo mysql_secure_installation
select one of the three levels of password validation policy(strong recommended).Set your password ,and then type y(yes) to all the questions , this will improve the security .
Step 5 : Once it has done. open MySQL by typing the following command :
sudo mysql
Step 6 : If you want to login to your MySQL server as root from an external program such as phpMyAdmin , then type these commands inside mysql.
mysql>ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'strong_password';
mysql>FLUSH PRIVILEGES;
mysql>exit;
After this you will be successfully able to run mysql , for this open terminal and type.
mysql -u root -p
Now type your password.
Congo! you are done with installing mysql.
Lesson from continuous deployment test. You MUST do this purge mysql-common. You CANNOT put mariadb and mysql in the same system, they want their own mysql-common and not sharing them. Which many other API wrapped around it to connect to those server.
And you must comment all the repo pointing to mariadb. Otherwise it will install the same version again from mariadb.
sudo apt-get purge mysql-common
# Put back the mysql-common , make sure you use the new mysql repo,
# remarks mariadb repo
sudo apt-get install software-properties-common
Always check whether any OTHER file or folder contains mariadb repo.
cd /etc/apt
fgrep -lR "maria"
The easy way for this is installing the synaptic package manager by typing the following command in the terminal:
sudo apt-get install synaptic
And then open synaptic by:
sudo synaptic
Then search for the package you have installed, mariadb, and mark it for complete removal and press apply.
And these commands to install mysql-server
sudo apt-get update
sudo apt-get install mysql-server
It's quite easy to install mysql on Ubuntu.
sudo apt-get update
sudo apt-get install mysql-server
You'll be asked to create a new password for root user. Set a good password and you're ready to go.
You can also follow this youtube videos for installation and basic understanding for Mysql
sudo apt-get update
sudo apt-get install mysql-server -y
if setup password
sudo mysql_secure_installation
if set new user
sudo mysql
>CREATE USER 'username'#'%' IDENTIFIED BY 'password';
>FLUSH PRIVILEGES;
>exit
sudo systemctl restart mysql

Connection time out installing mysql server in unix

I am trying to install mysql server in my AWS EC2 instance. I googled and executed the below command in the shell.
sudo yum install mysql-server
It throws the below connection timed out exception
Loaded plugins: priorities, update-motd, upgrade-helper
http://packages.us-west- 2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: [Errno 12] Timeout on http://packages.us-west-2.amazonaws.com/2014.03/main/201403504e47/x86_64/repodata/repomd.xml?instance_id=i-c82c93c3&region=us-west-2: (28, 'Connection timed out after 10001 milliseconds')
Trying other mirror.
Is this the right way to install mysql server?
Thanks.
installing mysql
From the current AWS EC2 documentation:
To install and start the LAMP web server
Connect to your instance.
To ensure that all of your software packages are up to date, perform a quick software update on your instance. This process may take a few minutes, but it is important to make sure you have the latest security updates and bug fixes.
Note
The -y option installs the updates without asking for confirmation. If you would like to examine the updates before installing, you can omit this option.
[ec2-user ~]$ sudo yum update -y
Now that your instance is current, you can install the Apache web server, MySQL, and PHP software packages. Use the yum groupinstall command to install multiple software packages and all related dependencies at the same time.
[ec2-user ~]$ sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"
Note
Non-Amazon Linux instances may have subtle differences in their group names. If the above command fails because of an invalid group name, use the yum grouplist command and scan the output for similar groups, such as "MySQL Database server" instead of "MySQL Database", and use the appropriate group name for your distribution.
Install the php-mysql package.
[ec2-user ~]$ sudo yum install -y php-mysql
I suppose you only need to install mysql, so you just need to run the 1st command, adapt the second to only grab mysql from the repositories, and skip the last one:
[ec2-user ~]$ sudo yum update -y
[ec2-user ~]$ sudo yum groupinstall -y "MySQL Database"
Depending on which version of linux you have installed (Amazon, Red Hat or CentOS), you may need to change the string "MySQL Database" to something else. The following command:
[ec2-user ~]$ sudo yum grouplist
Will list all the possible group install you may perform, so you need to filter it to get the right string:
[ec2-user ~]$ sudo yum grouplist | grep -i mysql
And choose the most appropriate one in that filtered result set.
network connectivity
Now, regarding your specific issue, the FAQs describes your problem as follow:
If the AMI cannot access the yum repositories, it will timeout and retry multiple times before completing the boot procedure. Possible reasons for this are restrictive firewall settings or VPC settings, which prevent access to the Amazon Linux AMI package repositories.
If you encounter this issue you can either modify your environment so that the Amazon Linux AMI can connect to its package repositories [...]
Unfortunately, no explanations are given as yo how you can change your environment to enable connectivity.
Apparently, by using the dashboard, you should be able to open outbound access to the port the yum servers are using:
AWS dashboard > ec2 > security groups > default group > outbound rule: ??? (HTTP*) 0.0.0.0/???
The usual port for yum server is 80, so just replace ??? above by 80 to have access to the repos. You also should replace 0.0.0.0 with the actual repository server address.
If this solution does not work, you might also try disabling the firewall altogether for the duration of the update:
[ec2-user ~]$ sudo /etc/init.d/iptables stop
<...Update commands as listed above...>
[ec2-user ~]$ sudo /etc/init.d/iptables start
Or
[ec2-user ~]$ sudo /sbin/service iptables stop
<...>
[ec2-user ~]$ sudo /sbin/service iptables start
I just delete all the files in /etc/resolv.conf dir

MySQL server not running as service

I Have Installed mysql-server as root with command :
sudo apt-get install mysql-server
i have configured and changes too many things related to the mysql-server Now the problem is that Mysql is not working as service
as it is not in /etc/init.d
I want the mysql server to be started at boot time means to make it the service.
Now what i have to do please help.
I find chkconfig easy to use: sudo chkconfig --list|grep mysql but it might be an outdated mode of handling it. Most of my servers have long used it but I find my desktop Ubuntu didn't have it and complains if I use it.
If you don't have chkconfig, do sudo apt-get install chkconfig
To turn it on: chkconfig mysql on