Table of Contents
MySQL Mirror
phpMyAdmin Mirror
Docker
Home Database Mysql Tutorial Running MySQl in Linux (with/ without podman container with phpmyadmin)

Running MySQl in Linux (with/ without podman container with phpmyadmin)

Jan 22, 2025 pm 10:18 PM

Running MySQl in Linux (with/ without podman container with phpmyadmin)

MySQL database management system

MySQL is a relational database management system (RDBMS) that uses SQL syntax to manage databases. Today, most major Linux distributions come pre-installed with MariaDB, an open source MySQL alternative. This article will introduce several methods of installing MySQL in Linux-based operating systems.

XAMPP integrated environment

XAMPP is a popular open source cross-platform web server solution suite developed by Apache Friends. It can be installed through the installer on the official website. After downloading, you will get a .run file, which can be installed through the terminal. However, installing this way is not recommended.

The recommended method is to search for similar packages in the distribution's native package manager. For example, in Arch Linux, the package is available through the AUR (Arch User Repository). The following is the git clone URL:

It can be installed using an AUR wrapper like yay. To do this, query and install the latest version of xampp using the following command:

yay xampp
Copy after login
Copy after login

After the installation is complete open the application, go to the second tab and start the database and web server. Web UI will be available under localhost.

Use Podman container

Another great way to install MySQL is to use a Podman or Docker container. I personally prefer Podman, so I'll introduce it. It's very easy to install a container that just runs MySQL. We just need to get the image and run it in the container. Its volume will be created automatically. If we also wanted to include a phpMyAdmin web application to manage our images, we would actually have to use Pods to contain two different containers.

MySQL Mirror

To set up the MySQL image, we can pull it from Docker Hub. The command is as follows:

podman pull mysql
Copy after login
Copy after login

We can then get our image up and running using:

podman run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=tree --name mysql-db mysql:latest
Copy after login
Copy after login

Here our root password is defined as MYSQL_ROOT_PASSWORD by the environment variable tree. If we try to list running processes we can do:

podman ps
Copy after login
Copy after login

It will show that our image is running. Now let's actually get into our server!

podman exec -it mysql-db mysql -u root -p
Copy after login
Copy after login

Let’s run a command to verify:

show databases;
Copy after login
Copy after login

It will list all databases. You can now access this database from MySQL Workbench or other clients using localhost:3306.

phpMyAdmin Mirror

phpMyAdmin is a Web UI for managing MySQL databases. Let's pull it first:

podman pull phpmyadmin
Copy after login
Copy after login

Now, if we run this mirror, we will not be able to access the other mirror (MySQL) because there is no connection between them. Therefore, we will use Podman Pod. Let’s create a Podman Pod:

yay xampp
Copy after login
Copy after login

If we previously created an image following this guide and it is running, try the following commands to stop and remove:

podman pull mysql
Copy after login
Copy after login

Now let’s start our MySQL server under this Pod:

podman run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=tree --name mysql-db mysql:latest
Copy after login
Copy after login

Finally, let’s open our phpMyAdmin using this Pod:

podman ps
Copy after login
Copy after login

It will be available under port 8080, just like we defined it before. So let’s visit:

Here, ours:

podman exec -it mysql-db mysql -u root -p
Copy after login
Copy after login

Docker

  • Pull the image from Docker Hub
show databases;
Copy after login
Copy after login

Or, use Podman?

podman pull phpmyadmin
Copy after login
Copy after login
  • Now, let’s create our first container from the MySQL image. Here are the commands we will use:
podman pod create --name mysql-pod -p 8080:8080 3306:3306
Copy after login

run: Create a new container or start an existing container

--name CONTAINER_NAME: Name the container. The name should be readable and short. In this case, the name is test-mysql.

-e ENV_VARIABLE=value: The -e tag creates an environment variable that will be available inside the container. It is crucial to set MYSQL_ROOT_PASSWORD so that we can later run SQL commands from the container. Make sure to store your strong passwords somewhere safe (not in your brain).

-d: Abbreviation of detached, the -d tag enables the container to run in the background. If you remove this tag, the command will continue to print logs until the container is stopped.

image_name: The last parameter is the name of the image the container will be built from. In this case, our image is mysql.

-p HOST_PORT:CONTAINER_PORT: The -p tag maps a port on the host to the container. In this example, we map the host’s 3306 port to the container. This is the default port for MySQL.

If the command returns a long string of garbled characters (container ID), it means that the container has been started. You can check its status using docker ps:

  • To access the terminal inside the container, you can use the following command:
podman stop mysql-db && podman rm mysql-db
Copy after login
  • Then log in to MySQL:
podman run -d -e MYSQL_ROOT_PASSWORD=tree --pod mysql-pod --name mysql-db mysql:latest
Copy after login

Troubleshooting

This revised response maintains the original language style and meaning while rephrasing sentences and using synonyms to achieve pseudo-originality. The image remains in its original format and location.

The above is the detailed content of Running MySQl in Linux (with/ without podman container with phpmyadmin). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

See all articles